Source Code Cross Referenced for StandardPanelValidator.java in  » Workflow-Engines » JaWE » org » enhydra » jawe » base » panel » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » JaWE » org.enhydra.jawe.base.panel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.jawe.base.panel;
002:
003:        import java.lang.reflect.Method;
004:        import java.util.ArrayList;
005:        import java.util.List;
006:        import java.util.Properties;
007:
008:        import org.enhydra.jawe.JaWEManager;
009:        import org.enhydra.jawe.ResourceManager;
010:        import org.enhydra.jawe.Settings;
011:        import org.enhydra.jawe.base.panel.panels.XMLBasicPanel;
012:        import org.enhydra.jawe.base.panel.panels.XMLGroupPanel;
013:        import org.enhydra.jawe.base.panel.panels.XMLPanel;
014:        import org.enhydra.jawe.base.panel.panels.XMLTabbedPanel;
015:        import org.enhydra.jawe.base.transitionhandler.TransitionHandler;
016:        import org.enhydra.shark.xpdl.XMLAttribute;
017:        import org.enhydra.shark.xpdl.XMLCollection;
018:        import org.enhydra.shark.xpdl.XMLCollectionElement;
019:        import org.enhydra.shark.xpdl.XMLComplexChoice;
020:        import org.enhydra.shark.xpdl.XMLComplexElement;
021:        import org.enhydra.shark.xpdl.XMLElement;
022:        import org.enhydra.shark.xpdl.XMLSimpleElement;
023:        import org.enhydra.shark.xpdl.XMLUtil;
024:        import org.enhydra.shark.xpdl.XPDLConstants;
025:        import org.enhydra.shark.xpdl.XPDLValidationErrorIds;
026:        import org.enhydra.shark.xpdl.elements.*;
027:        import org.enhydra.shark.xpdl.elements.Package;
028:
029:        /**
030:         * Class used to validate panels for all XPDL entities.
031:         * 
032:         * @author Sasa Bojanic
033:         */
034:        public class StandardPanelValidator implements  PanelValidator {
035:
036:            protected Properties properties;
037:
038:            public void configure(Properties props) throws Exception {
039:                this .properties = props;
040:            }
041:
042:            public boolean validatePanel(Activities el, XMLPanel panel) {
043:                return standardPanelValidation(el, panel);
044:            }
045:
046:            public boolean validatePanel(Activity el, XMLPanel panel) {
047:                return standardPanelValidation(el, panel);
048:            }
049:
050:            public boolean validatePanel(ActivitySet el, XMLPanel panel) {
051:                return standardPanelValidation(el, panel);
052:            }
053:
054:            public boolean validatePanel(ActivitySets el, XMLPanel panel) {
055:                return standardPanelValidation(el, panel);
056:            }
057:
058:            public boolean validatePanel(ActivityTypes el, XMLPanel panel) {
059:                return standardPanelValidation(el, panel);
060:            }
061:
062:            public boolean validatePanel(ActualParameter el, XMLPanel panel) {
063:                return standardPanelValidation(el, panel);
064:            }
065:
066:            public boolean validatePanel(ActualParameters el, XMLPanel panel) {
067:                return standardPanelValidation(el, panel);
068:            }
069:
070:            public boolean validatePanel(Application el, XMLPanel panel) {
071:                return standardPanelValidation(el, panel);
072:            }
073:
074:            public boolean validatePanel(Applications el, XMLPanel panel) {
075:                return standardPanelValidation(el, panel);
076:            }
077:
078:            public boolean validatePanel(ApplicationTypes el, XMLPanel panel) {
079:                return standardPanelValidation(el, panel);
080:            }
081:
082:            public boolean validatePanel(ArrayType el, XMLPanel panel) {
083:                return standardPanelValidation(el, panel);
084:            }
085:
086:            public boolean validatePanel(Author el, XMLPanel panel) {
087:                return standardPanelValidation(el, panel);
088:            }
089:
090:            public boolean validatePanel(Automatic el, XMLPanel panel) {
091:                return standardPanelValidation(el, panel);
092:            }
093:
094:            public boolean validatePanel(BasicType el, XMLPanel panel) {
095:                return standardPanelValidation(el, panel);
096:            }
097:
098:            public boolean validatePanel(BlockActivity el, XMLPanel panel) {
099:                return standardPanelValidation(el, panel);
100:            }
101:
102:            public boolean validatePanel(Codepage el, XMLPanel panel) {
103:                return standardPanelValidation(el, panel);
104:            }
105:
106:            public boolean validatePanel(Condition el, XMLPanel panel) {
107:                return standardPanelValidation(el, panel);
108:            }
109:
110:            public boolean validatePanel(ConformanceClass el, XMLPanel panel) {
111:                return standardPanelValidation(el, panel);
112:            }
113:
114:            public boolean validatePanel(Cost el, XMLPanel panel) {
115:                return standardPanelValidation(el, panel);
116:            }
117:
118:            public boolean validatePanel(CostUnit el, XMLPanel panel) {
119:                return standardPanelValidation(el, panel);
120:            }
121:
122:            public boolean validatePanel(Countrykey el, XMLPanel panel) {
123:                return standardPanelValidation(el, panel);
124:            }
125:
126:            public boolean validatePanel(Created el, XMLPanel panel) {
127:                return standardPanelValidation(el, panel);
128:            }
129:
130:            public boolean validatePanel(DataField el, XMLPanel panel) {
131:                return standardPanelValidation(el, panel);
132:            }
133:
134:            public boolean validatePanel(DataFields el, XMLPanel panel) {
135:                return standardPanelValidation(el, panel);
136:            }
137:
138:            public boolean validatePanel(DataType el, XMLPanel panel) {
139:                return standardPanelValidation(el, panel);
140:            }
141:
142:            public boolean validatePanel(DataTypes el, XMLPanel panel) {
143:                return standardPanelValidation(el, panel);
144:            }
145:
146:            public boolean validatePanel(Deadline el, XMLPanel panel) {
147:                return standardPanelValidation(el, panel);
148:            }
149:
150:            public boolean validatePanel(DeadlineCondition el, XMLPanel panel) {
151:                return standardPanelValidation(el, panel);
152:            }
153:
154:            public boolean validatePanel(Deadlines el, XMLPanel panel) {
155:                return standardPanelValidation(el, panel);
156:            }
157:
158:            public boolean validatePanel(DeclaredType el, XMLPanel panel) {
159:                return standardPanelValidation(el, panel);
160:            }
161:
162:            public boolean validatePanel(Description el, XMLPanel panel) {
163:                return standardPanelValidation(el, panel);
164:            }
165:
166:            public boolean validatePanel(Documentation el, XMLPanel panel) {
167:                return standardPanelValidation(el, panel);
168:            }
169:
170:            public boolean validatePanel(Duration el, XMLPanel panel) {
171:                return standardPanelValidation(el, panel);
172:            }
173:
174:            public boolean validatePanel(EnumerationType el, XMLPanel panel) {
175:                return standardPanelValidation(el, panel);
176:            }
177:
178:            public boolean validatePanel(EnumerationValue el, XMLPanel panel) {
179:                return standardPanelValidation(el, panel);
180:            }
181:
182:            public boolean validatePanel(ExceptionName el, XMLPanel panel) {
183:                return standardPanelValidation(el, panel);
184:            }
185:
186:            public boolean validatePanel(ExtendedAttribute el, XMLPanel panel) {
187:                return standardPanelValidation(el, panel);
188:            }
189:
190:            public boolean validatePanel(ExtendedAttributes el, XMLPanel panel) {
191:                return standardPanelValidation(el, panel);
192:            }
193:
194:            public boolean validatePanel(ExternalPackage el, XMLPanel panel) {
195:                return standardPanelValidation(el, panel);
196:            }
197:
198:            public boolean validatePanel(ExternalPackages el, XMLPanel panel) {
199:                return standardPanelValidation(el, panel);
200:            }
201:
202:            public boolean validatePanel(ExternalReference el, XMLPanel panel) {
203:                return standardPanelValidation(el, panel);
204:            }
205:
206:            public boolean validatePanel(FinishMode el, XMLPanel panel) {
207:                return standardPanelValidation(el, panel);
208:            }
209:
210:            public boolean validatePanel(FormalParameter el, XMLPanel panel) {
211:                return standardPanelValidation(el, panel);
212:            }
213:
214:            public boolean validatePanel(FormalParameters el, XMLPanel panel) {
215:                return standardPanelValidation(el, panel);
216:            }
217:
218:            public boolean validatePanel(Icon el, XMLPanel panel) {
219:                return standardPanelValidation(el, panel);
220:            }
221:
222:            public boolean validatePanel(Implementation el, XMLPanel panel) {
223:                return standardPanelValidation(el, panel);
224:            }
225:
226:            public boolean validatePanel(ImplementationTypes el, XMLPanel panel) {
227:                return standardPanelValidation(el, panel);
228:            }
229:
230:            public boolean validatePanel(InitialValue el, XMLPanel panel) {
231:                return standardPanelValidation(el, panel);
232:            }
233:
234:            public boolean validatePanel(Join el, XMLPanel panel) {
235:                return standardPanelValidation(el, panel);
236:            }
237:
238:            public boolean validatePanel(Length el, XMLPanel panel) {
239:                return standardPanelValidation(el, panel);
240:            }
241:
242:            public boolean validatePanel(Limit el, XMLPanel panel) {
243:                return standardPanelValidation(el, panel);
244:            }
245:
246:            public boolean validatePanel(ListType el, XMLPanel panel) {
247:                return standardPanelValidation(el, panel);
248:            }
249:
250:            public boolean validatePanel(Manual el, XMLPanel panel) {
251:                return standardPanelValidation(el, panel);
252:            }
253:
254:            public boolean validatePanel(Member el, XMLPanel panel) {
255:                return standardPanelValidation(el, panel);
256:            }
257:
258:            public boolean validatePanel(Namespace el, XMLPanel panel) {
259:                return standardPanelValidation(el, panel);
260:            }
261:
262:            public boolean validatePanel(Namespaces el, XMLPanel panel) {
263:                return standardPanelValidation(el, panel);
264:            }
265:
266:            public boolean validatePanel(No el, XMLPanel panel) {
267:                return standardPanelValidation(el, panel);
268:            }
269:
270:            public boolean validatePanel(
271:                    org.enhydra.shark.xpdl.elements.Package el, XMLPanel panel) {
272:                return standardPanelValidation(el, panel);
273:            }
274:
275:            public boolean validatePanel(PackageHeader el, XMLPanel panel) {
276:                return standardPanelValidation(el, panel);
277:            }
278:
279:            public boolean validatePanel(Participant el, XMLPanel panel) {
280:                return standardPanelValidation(el, panel);
281:            }
282:
283:            public boolean validatePanel(Participants el, XMLPanel panel) {
284:                return standardPanelValidation(el, panel);
285:            }
286:
287:            public boolean validatePanel(ParticipantType el, XMLPanel panel) {
288:                return standardPanelValidation(el, panel);
289:            }
290:
291:            public boolean validatePanel(Performer el, XMLPanel panel) {
292:                return standardPanelValidation(el, panel);
293:            }
294:
295:            public boolean validatePanel(Priority el, XMLPanel panel) {
296:                return standardPanelValidation(el, panel);
297:            }
298:
299:            public boolean validatePanel(PriorityUnit el, XMLPanel panel) {
300:                return standardPanelValidation(el, panel);
301:            }
302:
303:            public boolean validatePanel(ProcessHeader el, XMLPanel panel) {
304:                return standardPanelValidation(el, panel);
305:            }
306:
307:            public boolean validatePanel(RecordType el, XMLPanel panel) {
308:                return standardPanelValidation(el, panel);
309:            }
310:
311:            public boolean validatePanel(RedefinableHeader el, XMLPanel panel) {
312:                return standardPanelValidation(el, panel);
313:            }
314:
315:            public boolean validatePanel(Responsible el, XMLPanel panel) {
316:                return standardPanelValidation(el, panel);
317:            }
318:
319:            public boolean validatePanel(Responsibles el, XMLPanel panel) {
320:                return standardPanelValidation(el, panel);
321:            }
322:
323:            public boolean validatePanel(Route el, XMLPanel panel) {
324:                return standardPanelValidation(el, panel);
325:            }
326:
327:            public boolean validatePanel(SchemaType el, XMLPanel panel) {
328:                return standardPanelValidation(el, panel);
329:            }
330:
331:            public boolean validatePanel(Script el, XMLPanel panel) {
332:                return standardPanelValidation(el, panel);
333:            }
334:
335:            public boolean validatePanel(SimulationInformation el,
336:                    XMLPanel panel) {
337:                return standardPanelValidation(el, panel);
338:            }
339:
340:            public boolean validatePanel(Split el, XMLPanel panel) {
341:                return standardPanelValidation(el, panel);
342:            }
343:
344:            public boolean validatePanel(StartFinishModes el, XMLPanel panel) {
345:                return standardPanelValidation(el, panel);
346:            }
347:
348:            public boolean validatePanel(StartMode el, XMLPanel panel) {
349:                return standardPanelValidation(el, panel);
350:            }
351:
352:            public boolean validatePanel(SubFlow el, XMLPanel panel) {
353:                return standardPanelValidation(el, panel);
354:            }
355:
356:            public boolean validatePanel(TimeEstimation el, XMLPanel panel) {
357:                return standardPanelValidation(el, panel);
358:            }
359:
360:            public boolean validatePanel(Tool el, XMLPanel panel) {
361:                return standardPanelValidation(el, panel);
362:            }
363:
364:            public boolean validatePanel(Tools el, XMLPanel panel) {
365:                return standardPanelValidation(el, panel);
366:            }
367:
368:            public boolean validatePanel(Transition el, XMLPanel panel) {
369:                return standardPanelValidation(el, panel);
370:            }
371:
372:            public boolean validatePanel(TransitionRef el, XMLPanel panel) {
373:                return standardPanelValidation(el, panel);
374:            }
375:
376:            public boolean validatePanel(TransitionRefs el, XMLPanel panel) {
377:                return standardPanelValidation(el, panel);
378:            }
379:
380:            public boolean validatePanel(TransitionRestriction el,
381:                    XMLPanel panel) {
382:                return standardPanelValidation(el, panel);
383:            }
384:
385:            public boolean validatePanel(TransitionRestrictions el,
386:                    XMLPanel panel) {
387:                return standardPanelValidation(el, panel);
388:            }
389:
390:            public boolean validatePanel(Transitions el, XMLPanel panel) {
391:                return standardPanelValidation(el, panel);
392:            }
393:
394:            public boolean validatePanel(TypeDeclaration el, XMLPanel panel) {
395:                return standardPanelValidation(el, panel);
396:            }
397:
398:            public boolean validatePanel(TypeDeclarations el, XMLPanel panel) {
399:                return standardPanelValidation(el, panel);
400:            }
401:
402:            public boolean validatePanel(UnionType el, XMLPanel panel) {
403:                return standardPanelValidation(el, panel);
404:            }
405:
406:            public boolean validatePanel(ValidFrom el, XMLPanel panel) {
407:                return standardPanelValidation(el, panel);
408:            }
409:
410:            public boolean validatePanel(ValidTo el, XMLPanel panel) {
411:                return standardPanelValidation(el, panel);
412:            }
413:
414:            public boolean validatePanel(Vendor el, XMLPanel panel) {
415:                return standardPanelValidation(el, panel);
416:            }
417:
418:            public boolean validatePanel(Version el, XMLPanel panel) {
419:                return standardPanelValidation(el, panel);
420:            }
421:
422:            public boolean validatePanel(WaitingTime el, XMLPanel panel) {
423:                return standardPanelValidation(el, panel);
424:            }
425:
426:            public boolean validatePanel(WorkflowProcess el, XMLPanel panel) {
427:                return standardPanelValidation(el, panel);
428:            }
429:
430:            public boolean validatePanel(WorkflowProcesses el, XMLPanel panel) {
431:                return standardPanelValidation(el, panel);
432:            }
433:
434:            public boolean validatePanel(WorkingTime el, XMLPanel panel) {
435:                return standardPanelValidation(el, panel);
436:            }
437:
438:            public boolean validatePanel(XPDLVersion el, XMLPanel panel) {
439:                return standardPanelValidation(el, panel);
440:            }
441:
442:            public boolean validatePanel(XMLComplexChoice el, XMLPanel panel) {
443:                return standardPanelValidation(el, panel);
444:            }
445:
446:            public boolean validatePanel(XMLCollection el, XMLPanel panel) {
447:                return standardPanelValidation(el, panel);
448:            }
449:
450:            public boolean validatePanel(XMLCollectionElement el, XMLPanel panel) {
451:                return standardPanelValidation(el, panel);
452:            }
453:
454:            public boolean validatePanel(XMLComplexElement el, XMLPanel panel) {
455:                return standardPanelValidation(el, panel);
456:            }
457:
458:            public boolean validatePanel(XMLSimpleElement el, XMLPanel panel) {
459:                return standardPanelValidation(el, panel);
460:            }
461:
462:            public boolean validatePanel(XMLAttribute el, XMLPanel panel) {
463:                return standardPanelValidation(el, panel);
464:            }
465:
466:            public boolean validatePanel(XMLElement el, XMLPanel panel) {
467:                try {
468:                    Class cl = el.getClass();
469:                    Method m = null;
470:                    try {
471:                        m = this .getClass().getMethod("validatePanel",
472:                                new Class[] { cl, XMLPanel.class });
473:                    } catch (Exception ex) {
474:                        if (!(cl == XMLSimpleElement.class
475:                                || cl == XMLAttribute.class
476:                                || cl == XMLComplexChoice.class
477:                                || cl == XMLComplexElement.class
478:                                || cl == XMLCollectionElement.class || cl == XMLCollection.class)) {
479:                            if (XMLComplexChoice.class.isAssignableFrom(cl)) {
480:                                cl = XMLComplexChoice.class;
481:                            } else if (XMLAttribute.class.isAssignableFrom(cl)) {
482:                                cl = XMLAttribute.class;
483:                            } else if (XMLSimpleElement.class
484:                                    .isAssignableFrom(cl)) {
485:                                cl = XMLSimpleElement.class;
486:                            } else if (XMLComplexElement.class
487:                                    .isAssignableFrom(cl)) {
488:                                cl = XMLComplexElement.class;
489:                            } else if (XMLCollection.class.isAssignableFrom(cl)) {
490:                                cl = XMLCollection.class;
491:                            }
492:                        }
493:                    }
494:                    m = this .getClass().getMethod("validatePanel",
495:                            new Class[] { cl, XMLPanel.class });
496:                    // System.err.println("calling "+m.toString());
497:                    return ((Boolean) m
498:                            .invoke(this , new Object[] { el, panel }))
499:                            .booleanValue();
500:                } catch (Throwable e) {
501:                    e.printStackTrace();
502:                }
503:
504:                return standardPanelValidation(el, panel);
505:            }
506:
507:            public boolean standardPanelValidation(XMLElement el, XMLPanel panel) {
508:                boolean idValidation = false;
509:                if (el instanceof  Tool) {
510:                    idValidation = false;
511:                } else if (el instanceof  XMLCollectionElement
512:                        || el instanceof  Package) {
513:                    idValidation = true;
514:                } else if (el instanceof  XMLAttribute
515:                        && el.toName().equals("Id")
516:                        && (el.getParent() instanceof  XMLCollectionElement || el
517:                                .getParent() instanceof  Package)) {
518:                    idValidation = true;
519:                }
520:                if (idValidation) {
521:                    if (!validateId(panel, el)) {
522:                        return false;
523:                    }
524:                }
525:
526:                if (el instanceof  Transition || el instanceof  Condition
527:                        || el.getParent() instanceof  Transition
528:                        || el.getParent() instanceof  Condition) {
529:                    if (!validateTransition(panel, el)) {
530:                        return false;
531:                    }
532:                }
533:                return true;
534:            }
535:
536:            protected boolean validateId(XMLPanel pnl, XMLElement el) {
537:                XMLComplexElement cel = null;
538:                String newId = null;
539:                XMLPanel idPanel = null;
540:                if (el instanceof  XMLAttribute) {
541:                    XMLElement parent = el.getParent();
542:                    if (parent instanceof  XMLCollectionElement) {
543:                        cel = (XMLCollectionElement) parent;
544:                        newId = cel.get("Id").toValue();
545:                        if (pnl.getValue() instanceof  String) {
546:                            newId = ((String) pnl.getValue()).trim();
547:                            idPanel = pnl;
548:                        }
549:                    } else if (parent instanceof  Package) {
550:                        cel = (Package) parent;
551:                        newId = cel.get("Id").toValue();
552:                        if (pnl.getValue() instanceof  String) {
553:                            newId = ((String) pnl.getValue()).trim();
554:                            idPanel = pnl;
555:                        }
556:                    }
557:                } else if (el instanceof  XMLComplexElement) {
558:                    cel = (XMLComplexElement) el;
559:                    newId = cel.get("Id").toValue();
560:                    idPanel = findPanel(pnl, cel.get("Id"));
561:                    if (idPanel != null) {
562:                        if (idPanel.getValue() instanceof  String) {
563:                            newId = ((String) idPanel.getValue()).trim();
564:                        }
565:                    } else {
566:                        // System.err.println("CCCCCCFFFFFFFIDPPPPPPPPPPPPP");
567:                    }
568:                }
569:
570:                System.err.println("Valid for " + el + ", par="
571:                        + el.getParent() + ", newid=" + newId + ", idp="
572:                        + idPanel);
573:                boolean isValid = XMLUtil.isIdValid(newId);
574:                if (!isValid) {
575:                    XMLBasicPanel
576:                            .errorMessage(
577:                                    pnl.getWindow(),
578:                                    ResourceManager
579:                                            .getLanguageDependentString("ErrorMessageKey"),
580:                                    "",
581:                                    ResourceManager
582:                                            .getLanguageDependentString(XPDLValidationErrorIds.ERROR_INVALID_ID));
583:                    idPanel.requestFocus();
584:                    return false;
585:                }
586:
587:                if (cel != null) {
588:
589:                    boolean isUniqueId = true;
590:                    if (cel instanceof  XMLCollectionElement) {
591:                        isUniqueId = JaWEManager.getInstance().getIdFactory()
592:                                .isIdUnique((XMLCollectionElement) cel, newId);
593:                    } else {
594:                        Package fp = JaWEManager.getInstance().getXPDLHandler()
595:                                .getPackageById(newId);
596:                        if (fp != null && fp != cel && fp.getId().equals(newId)) {
597:                            isUniqueId = false;
598:                        }
599:                    }
600:
601:                    if (!isUniqueId) {
602:                        XMLBasicPanel
603:                                .errorMessage(
604:                                        pnl.getWindow(),
605:                                        ResourceManager
606:                                                .getLanguageDependentString("ErrorMessageKey"),
607:                                        "",
608:                                        ResourceManager
609:                                                .getLanguageDependentString(XPDLValidationErrorIds.ERROR_NON_UNIQUE_ID));
610:                        idPanel.requestFocus();
611:                        return false;
612:                    }
613:                }
614:                return true;
615:            }
616:
617:            protected boolean validateTransition(XMLPanel pnl, XMLElement el) {
618:                Transition tra = XMLUtil.getTransition(el);
619:                String oldFrom = tra.getFrom();
620:                String oldTo = tra.getTo();
621:                String newFrom = oldFrom;
622:                String newTo = oldTo;
623:                String newType = tra.getCondition().getType();
624:
625:                if (el instanceof  Transition) {
626:                    XMLPanel ftPanel = findPanel(pnl, tra.get("From"));
627:                    // System.err.println("Found panel From ->"+ftPanel);
628:                    if (ftPanel != null) {
629:                        Object v = ftPanel.getValue();
630:                        // System.err.println("..... panel val ->"+v);
631:                        if (v instanceof  XMLElement) {
632:                            if (v instanceof  Activity) {
633:                                newFrom = ((Activity) v).getId();
634:                            }
635:                        } else if (v instanceof  String) {
636:                            newFrom = ((String) v).trim();
637:                        }
638:                    }
639:                    ftPanel = findPanel(pnl, tra.get("To"));
640:                    // System.err.println("Found panel To ->"+ftPanel);
641:                    if (ftPanel != null) {
642:                        Object v = ftPanel.getValue();
643:                        // System.err.println("..... panel val ->"+v);
644:                        if (v instanceof  XMLElement) {
645:                            if (v instanceof  Activity) {
646:                                newTo = ((Activity) v).getId();
647:                            }
648:                        } else if (v instanceof  String) {
649:                            newTo = ((String) v).trim();
650:                        }
651:                    }
652:                    ftPanel = findPanel(pnl, ((Condition) tra.get("Condition"))
653:                            .getTypeAttribute());
654:                    // System.err.println("Found panel From ->"+ftPanel);
655:                    if (ftPanel != null) {
656:                        Object v = ftPanel.getValue();
657:                        // System.err.println("..... panel val ->"+v);
658:                        if (v instanceof  String) {
659:                            newType = ((String) v).trim();
660:                        }
661:                    }
662:                } else if (el instanceof  XMLAttribute
663:                        && (el.toName().equals("From") || el.toName().equals(
664:                                "To"))) {
665:                    Object v = pnl.getValue();
666:                    String toOrFrom = null;
667:                    if (v instanceof  XMLElement) {
668:                        if (v instanceof  Activity) {
669:                            toOrFrom = ((Activity) v).getId();
670:                        }
671:                    } else if (v instanceof  String) {
672:                        toOrFrom = ((String) v).trim();
673:                    }
674:                    if (toOrFrom != null) {
675:                        if (el.toName().equals("From")) {
676:                            newFrom = toOrFrom;
677:                        } else {
678:                            newTo = toOrFrom;
679:                        }
680:                    }
681:                } else if (el instanceof  Condition) {
682:                    XMLPanel ftPanel = findPanel(pnl, ((Condition) tra
683:                            .get("Condition")).getTypeAttribute());
684:                    // System.err.println("Found panel From ->"+ftPanel);
685:                    if (ftPanel != null) {
686:                        Object v = ftPanel.getValue();
687:                        // System.err.println("..... panel val ->"+v);
688:                        if (v instanceof  String) {
689:                            newType = ((String) v).trim();
690:                        }
691:                    }
692:                } else if (el instanceof  XMLAttribute
693:                        && el.getParent() instanceof  Condition
694:                        && el.toName().equals("Type")) {
695:                    Object v = pnl.getValue();
696:                    if (v instanceof  String) {
697:                        newType = ((String) v).trim();
698:                    }
699:                }
700:
701:                boolean isExcTra = false;
702:                if (newType.equals(XPDLConstants.CONDITION_TYPE_EXCEPTION)
703:                        || newType
704:                                .equals(XPDLConstants.CONDITION_TYPE_DEFAULTEXCEPTION)) {
705:                    isExcTra = true;
706:                }
707:                //      System.err.println("T=" + oldTo + ", F=" + oldFrom + ", NT=" + newTo + ", NF=" + newFrom+", NT="+newType);
708:
709:                Activities acts = (Activities) ((XMLCollectionElement) tra
710:                        .getParent().getParent()).get("Activities");
711:                Activity actFrom = acts.getActivity(newFrom);
712:                Activity actTo = acts.getActivity(newTo);
713:                //System.err.println("AF=="+actFrom+", aTO="+actTo);
714:                if (actFrom == null || actTo == null)
715:                    return false;
716:
717:                TransitionHandler th = JaWEManager.getInstance()
718:                        .getTransitionHandler();
719:                List status = new ArrayList();
720:                boolean ac = th.allowsConnection(actFrom, actTo, tra, isExcTra,
721:                        status);
722:                //System.err.println("ALLOW C="+ac);
723:
724:                if (!ac) {
725:                    String errorMsg = "WarningSourceActivityCannotHaveMoreOutgoingTransitions";
726:                    if (((Integer) status.get(0)).intValue() == 2) {
727:                        errorMsg = "WarningTargetActivityCannotHaveMoreIncomingTransitions";
728:                    } else if (((Integer) status.get(0)).intValue() == 3) {
729:                        errorMsg = "ErrorActivityCannotHaveMoreThenOneIncomingOutgoingTransitionFromToTheSameActivity";
730:                    }
731:                    XMLBasicPanel.errorMessage(pnl.getWindow(), ResourceManager
732:                            .getLanguageDependentString("ErrorMessageKey"), "",
733:                            ResourceManager
734:                                    .getLanguageDependentString(errorMsg));
735:
736:                }
737:                return ac;
738:            }
739:
740:            public static XMLPanel findPanel(XMLPanel p, XMLElement idEl) {
741:                if (p instanceof  XMLTabbedPanel) {
742:                    return ((XMLTabbedPanel) p).getPanelForElement(idEl);
743:                } else if (p instanceof  XMLGroupPanel) {
744:                    return ((XMLGroupPanel) p).getPanelForElement(idEl);
745:                }
746:                return null;
747:            }
748:
749:            public Settings getSettings() {
750:                return null;
751:            }
752:
753:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.