001: package org.enhydra.jawe.base.label;
002:
003: import java.lang.reflect.Method;
004:
005: import org.enhydra.jawe.JaWEComponent;
006: import org.enhydra.jawe.Settings;
007: import org.enhydra.shark.xpdl.XMLAttribute;
008: import org.enhydra.shark.xpdl.XMLCollection;
009: import org.enhydra.shark.xpdl.XMLCollectionElement;
010: import org.enhydra.shark.xpdl.XMLComplexChoice;
011: import org.enhydra.shark.xpdl.XMLComplexElement;
012: import org.enhydra.shark.xpdl.XMLElement;
013: import org.enhydra.shark.xpdl.XMLEmptyChoiceElement;
014: import org.enhydra.shark.xpdl.XMLSimpleElement;
015: import org.enhydra.shark.xpdl.elements.Activities;
016: import org.enhydra.shark.xpdl.elements.Activity;
017: import org.enhydra.shark.xpdl.elements.ActivitySet;
018: import org.enhydra.shark.xpdl.elements.ActivitySets;
019: import org.enhydra.shark.xpdl.elements.ActivityTypes;
020: import org.enhydra.shark.xpdl.elements.ActualParameter;
021: import org.enhydra.shark.xpdl.elements.ActualParameters;
022: import org.enhydra.shark.xpdl.elements.Application;
023: import org.enhydra.shark.xpdl.elements.ApplicationTypes;
024: import org.enhydra.shark.xpdl.elements.Applications;
025: import org.enhydra.shark.xpdl.elements.ArrayType;
026: import org.enhydra.shark.xpdl.elements.Author;
027: import org.enhydra.shark.xpdl.elements.Automatic;
028: import org.enhydra.shark.xpdl.elements.BasicType;
029: import org.enhydra.shark.xpdl.elements.BlockActivity;
030: import org.enhydra.shark.xpdl.elements.Codepage;
031: import org.enhydra.shark.xpdl.elements.Condition;
032: import org.enhydra.shark.xpdl.elements.ConformanceClass;
033: import org.enhydra.shark.xpdl.elements.Cost;
034: import org.enhydra.shark.xpdl.elements.CostUnit;
035: import org.enhydra.shark.xpdl.elements.Countrykey;
036: import org.enhydra.shark.xpdl.elements.Created;
037: import org.enhydra.shark.xpdl.elements.DataField;
038: import org.enhydra.shark.xpdl.elements.DataFields;
039: import org.enhydra.shark.xpdl.elements.DataType;
040: import org.enhydra.shark.xpdl.elements.DataTypes;
041: import org.enhydra.shark.xpdl.elements.Deadline;
042: import org.enhydra.shark.xpdl.elements.DeadlineCondition;
043: import org.enhydra.shark.xpdl.elements.Deadlines;
044: import org.enhydra.shark.xpdl.elements.DeclaredType;
045: import org.enhydra.shark.xpdl.elements.Description;
046: import org.enhydra.shark.xpdl.elements.Documentation;
047: import org.enhydra.shark.xpdl.elements.Duration;
048: import org.enhydra.shark.xpdl.elements.EnumerationType;
049: import org.enhydra.shark.xpdl.elements.EnumerationValue;
050: import org.enhydra.shark.xpdl.elements.ExceptionName;
051: import org.enhydra.shark.xpdl.elements.ExtendedAttribute;
052: import org.enhydra.shark.xpdl.elements.ExtendedAttributes;
053: import org.enhydra.shark.xpdl.elements.ExternalPackage;
054: import org.enhydra.shark.xpdl.elements.ExternalPackages;
055: import org.enhydra.shark.xpdl.elements.ExternalReference;
056: import org.enhydra.shark.xpdl.elements.FinishMode;
057: import org.enhydra.shark.xpdl.elements.FormalParameter;
058: import org.enhydra.shark.xpdl.elements.FormalParameters;
059: import org.enhydra.shark.xpdl.elements.Icon;
060: import org.enhydra.shark.xpdl.elements.Implementation;
061: import org.enhydra.shark.xpdl.elements.ImplementationTypes;
062: import org.enhydra.shark.xpdl.elements.InitialValue;
063: import org.enhydra.shark.xpdl.elements.Join;
064: import org.enhydra.shark.xpdl.elements.Length;
065: import org.enhydra.shark.xpdl.elements.Limit;
066: import org.enhydra.shark.xpdl.elements.ListType;
067: import org.enhydra.shark.xpdl.elements.Manual;
068: import org.enhydra.shark.xpdl.elements.Member;
069: import org.enhydra.shark.xpdl.elements.Namespace;
070: import org.enhydra.shark.xpdl.elements.Namespaces;
071: import org.enhydra.shark.xpdl.elements.No;
072: import org.enhydra.shark.xpdl.elements.PackageHeader;
073: import org.enhydra.shark.xpdl.elements.Participant;
074: import org.enhydra.shark.xpdl.elements.ParticipantType;
075: import org.enhydra.shark.xpdl.elements.Participants;
076: import org.enhydra.shark.xpdl.elements.Performer;
077: import org.enhydra.shark.xpdl.elements.Priority;
078: import org.enhydra.shark.xpdl.elements.PriorityUnit;
079: import org.enhydra.shark.xpdl.elements.ProcessHeader;
080: import org.enhydra.shark.xpdl.elements.RecordType;
081: import org.enhydra.shark.xpdl.elements.RedefinableHeader;
082: import org.enhydra.shark.xpdl.elements.Responsible;
083: import org.enhydra.shark.xpdl.elements.Responsibles;
084: import org.enhydra.shark.xpdl.elements.Route;
085: import org.enhydra.shark.xpdl.elements.SchemaType;
086: import org.enhydra.shark.xpdl.elements.Script;
087: import org.enhydra.shark.xpdl.elements.SimulationInformation;
088: import org.enhydra.shark.xpdl.elements.Split;
089: import org.enhydra.shark.xpdl.elements.StartFinishModes;
090: import org.enhydra.shark.xpdl.elements.StartMode;
091: import org.enhydra.shark.xpdl.elements.SubFlow;
092: import org.enhydra.shark.xpdl.elements.TimeEstimation;
093: import org.enhydra.shark.xpdl.elements.Tool;
094: import org.enhydra.shark.xpdl.elements.Tools;
095: import org.enhydra.shark.xpdl.elements.Transition;
096: import org.enhydra.shark.xpdl.elements.TransitionRef;
097: import org.enhydra.shark.xpdl.elements.TransitionRefs;
098: import org.enhydra.shark.xpdl.elements.TransitionRestriction;
099: import org.enhydra.shark.xpdl.elements.TransitionRestrictions;
100: import org.enhydra.shark.xpdl.elements.Transitions;
101: import org.enhydra.shark.xpdl.elements.TypeDeclaration;
102: import org.enhydra.shark.xpdl.elements.TypeDeclarations;
103: import org.enhydra.shark.xpdl.elements.UnionType;
104: import org.enhydra.shark.xpdl.elements.ValidFrom;
105: import org.enhydra.shark.xpdl.elements.ValidTo;
106: import org.enhydra.shark.xpdl.elements.Vendor;
107: import org.enhydra.shark.xpdl.elements.Version;
108: import org.enhydra.shark.xpdl.elements.WaitingTime;
109: import org.enhydra.shark.xpdl.elements.WorkflowProcess;
110: import org.enhydra.shark.xpdl.elements.WorkflowProcesses;
111: import org.enhydra.shark.xpdl.elements.WorkingTime;
112: import org.enhydra.shark.xpdl.elements.XPDLVersion;
113:
114: /**
115: * Used to generate labels for all XPDL entities.
116: *
117: * @author Sasa Bojanic
118: */
119: public class StandardLabelGenerator implements LabelGenerator {
120:
121: protected LabelGeneratorSettings settings;
122:
123: public StandardLabelGenerator() {
124: settings = new LabelGeneratorSettings();
125: settings.init((JaWEComponent) null);
126: }
127:
128: public StandardLabelGenerator(LabelGeneratorSettings settings) {
129: this .settings = settings;
130: this .settings.init((JaWEComponent) null);
131: }
132:
133: public String getLabel(Activities el) {
134: return generateStandardLabel(el);
135: }
136:
137: public String getLabel(Activity el) {
138: return generateStandardLabel(el);
139: }
140:
141: public String getLabel(ActivitySet el) {
142: return generateStandardLabel(el);
143: }
144:
145: public String getLabel(ActivitySets el) {
146: return generateStandardLabel(el);
147: }
148:
149: public String getLabel(ActivityTypes el) {
150: return generateStandardLabel(el);
151: }
152:
153: public String getLabel(ActualParameter el) {
154: return generateStandardLabel(el);
155: }
156:
157: public String getLabel(ActualParameters el) {
158: return generateStandardLabel(el);
159: }
160:
161: public String getLabel(Application el) {
162: return generateStandardLabel(el);
163: }
164:
165: public String getLabel(Applications el) {
166: return generateStandardLabel(el);
167: }
168:
169: public String getLabel(ApplicationTypes el) {
170: return generateStandardLabel(el);
171: }
172:
173: public String getLabel(ArrayType el) {
174: // return XMLUtil.getLanguageDependentString("SubTypeKey");
175: return generateStandardLabel(el);
176: }
177:
178: public String getLabel(Author el) {
179: return generateStandardLabel(el);
180: }
181:
182: public String getLabel(Automatic el) {
183: return generateStandardLabel(el);
184: }
185:
186: public String getLabel(BasicType el) {
187: // return XMLUtil.getLanguageDependentString("SubTypeKey");
188: return generateStandardLabel(el);
189: }
190:
191: public String getLabel(BlockActivity el) {
192: return generateStandardLabel(el);
193: }
194:
195: public String getLabel(Codepage el) {
196: return generateStandardLabel(el);
197: }
198:
199: public String getLabel(Condition el) {
200: return generateStandardLabel(el);
201: }
202:
203: public String getLabel(ConformanceClass el) {
204: return generateStandardLabel(el);
205: }
206:
207: public String getLabel(Cost el) {
208: return generateStandardLabel(el);
209: }
210:
211: public String getLabel(CostUnit el) {
212: return generateStandardLabel(el);
213: }
214:
215: public String getLabel(Countrykey el) {
216: return generateStandardLabel(el);
217: }
218:
219: public String getLabel(Created el) {
220: return generateStandardLabel(el);
221: }
222:
223: public String getLabel(DataField el) {
224: return generateStandardLabel(el);
225: }
226:
227: public String getLabel(DataFields el) {
228: return generateStandardLabel(el);
229: }
230:
231: public String getLabel(DataType el) {
232: return generateStandardLabel(el);
233: }
234:
235: public String getLabel(DataTypes el) {
236: return settings.getLanguageDependentString("TypeKey");
237: }
238:
239: public String getLabel(Deadline el) {
240: return generateStandardLabel(el);
241: }
242:
243: public String getLabel(DeadlineCondition el) {
244: return generateStandardLabel(el);
245: }
246:
247: public String getLabel(Deadlines el) {
248: return generateStandardLabel(el);
249: }
250:
251: public String getLabel(DeclaredType el) {
252: // return XMLUtil.getLanguageDependentString("SubTypeKey");
253: return generateStandardLabel(el);
254: }
255:
256: public String getLabel(Description el) {
257: return generateStandardLabel(el);
258: }
259:
260: public String getLabel(Documentation el) {
261: return generateStandardLabel(el);
262: }
263:
264: public String getLabel(Duration el) {
265: return generateStandardLabel(el);
266: }
267:
268: public String getLabel(EnumerationType el) {
269: return generateStandardLabel(el);
270: }
271:
272: public String getLabel(EnumerationValue el) {
273: return generateStandardLabel(el);
274: }
275:
276: public String getLabel(ExceptionName el) {
277: return generateStandardLabel(el);
278: }
279:
280: public String getLabel(ExtendedAttribute el) {
281: return generateStandardLabel(el);
282: }
283:
284: public String getLabel(ExtendedAttributes el) {
285: return generateStandardLabel(el);
286: }
287:
288: public String getLabel(ExternalPackage el) {
289: return generateStandardLabel(el);
290: }
291:
292: public String getLabel(ExternalPackages el) {
293: return generateStandardLabel(el);
294: }
295:
296: public String getLabel(ExternalReference el) {
297: return generateStandardLabel(el);
298: }
299:
300: public String getLabel(FinishMode el) {
301: return generateStandardLabel(el);
302: }
303:
304: public String getLabel(FormalParameter el) {
305: return generateStandardLabel(el);
306: }
307:
308: public String getLabel(FormalParameters el) {
309: return generateStandardLabel(el);
310: }
311:
312: public String getLabel(Icon el) {
313: return generateStandardLabel(el);
314: }
315:
316: public String getLabel(Implementation el) {
317: return generateStandardLabel(el);
318: }
319:
320: public String getLabel(ImplementationTypes el) {
321: return generateStandardLabel(el);
322: }
323:
324: public String getLabel(InitialValue el) {
325: return generateStandardLabel(el);
326: }
327:
328: public String getLabel(Join el) {
329: return settings.getLanguageDependentString("JoinTypeKey");
330: }
331:
332: public String getLabel(Length el) {
333: return generateStandardLabel(el);
334: }
335:
336: public String getLabel(Limit el) {
337: return generateStandardLabel(el);
338: }
339:
340: public String getLabel(ListType el) {
341: return generateStandardLabel(el);
342: // return XMLUtil.getLanguageDependentString("SubTypeKey");
343: }
344:
345: public String getLabel(Manual el) {
346: return generateStandardLabel(el);
347: }
348:
349: public String getLabel(Member el) {
350: return generateStandardLabel(el);
351: }
352:
353: public String getLabel(Namespace el) {
354: return generateStandardLabel(el);
355: }
356:
357: public String getLabel(Namespaces el) {
358: return generateStandardLabel(el);
359: }
360:
361: public String getLabel(No el) {
362: return generateStandardLabel(el);
363: }
364:
365: public String getLabel(org.enhydra.shark.xpdl.elements.Package el) {
366: return generateStandardLabel(el);
367: }
368:
369: public String getLabel(PackageHeader el) {
370: return generateStandardLabel(el);
371: }
372:
373: public String getLabel(Participant el) {
374: return generateStandardLabel(el);
375: }
376:
377: public String getLabel(Participants el) {
378: return generateStandardLabel(el);
379: }
380:
381: public String getLabel(ParticipantType el) {
382: return generateStandardLabel(el);
383: }
384:
385: public String getLabel(Performer el) {
386: return generateStandardLabel(el);
387: }
388:
389: public String getLabel(Priority el) {
390: return generateStandardLabel(el);
391: }
392:
393: public String getLabel(PriorityUnit el) {
394: return generateStandardLabel(el);
395: }
396:
397: public String getLabel(ProcessHeader el) {
398: return generateStandardLabel(el);
399: }
400:
401: public String getLabel(RecordType el) {
402: return generateStandardLabel(el);
403: }
404:
405: public String getLabel(RedefinableHeader el) {
406: return generateStandardLabel(el);
407: }
408:
409: public String getLabel(Responsible el) {
410: return generateStandardLabel(el);
411: }
412:
413: public String getLabel(Responsibles el) {
414: return generateStandardLabel(el);
415: }
416:
417: public String getLabel(Route el) {
418: return generateStandardLabel(el);
419: }
420:
421: public String getLabel(SchemaType el) {
422: return generateStandardLabel(el);
423: }
424:
425: public String getLabel(Script el) {
426: return generateStandardLabel(el);
427: }
428:
429: public String getLabel(SimulationInformation el) {
430: return generateStandardLabel(el);
431: }
432:
433: public String getLabel(Split el) {
434: return settings.getLanguageDependentString("SplitTypeKey");
435: }
436:
437: public String getLabel(StartFinishModes el) {
438: return generateStandardLabel(el.getParent());
439: }
440:
441: public String getLabel(StartMode el) {
442: return generateStandardLabel(el);
443: }
444:
445: public String getLabel(SubFlow el) {
446: return generateStandardLabel(el);
447: }
448:
449: public String getLabel(TimeEstimation el) {
450: return generateStandardLabel(el);
451: }
452:
453: public String getLabel(Tool el) {
454: return generateStandardLabel(el);
455: }
456:
457: public String getLabel(Tools el) {
458: return generateStandardLabel(el);
459: }
460:
461: public String getLabel(Transition el) {
462: return generateStandardLabel(el);
463: }
464:
465: public String getLabel(TransitionRef el) {
466: return generateStandardLabel(el);
467: }
468:
469: public String getLabel(TransitionRefs el) {
470: return generateStandardLabel(el);
471: }
472:
473: public String getLabel(TransitionRestriction el) {
474: return generateStandardLabel(el);
475: }
476:
477: public String getLabel(TransitionRestrictions el) {
478: return generateStandardLabel(el);
479: }
480:
481: public String getLabel(Transitions el) {
482: return generateStandardLabel(el);
483: }
484:
485: public String getLabel(TypeDeclaration el) {
486: return generateStandardLabel(el);
487: }
488:
489: public String getLabel(TypeDeclarations el) {
490: return generateStandardLabel(el);
491: }
492:
493: public String getLabel(UnionType el) {
494: return generateStandardLabel(el);
495: }
496:
497: public String getLabel(ValidFrom el) {
498: return generateStandardLabel(el);
499: }
500:
501: public String getLabel(ValidTo el) {
502: return generateStandardLabel(el);
503: }
504:
505: public String getLabel(Vendor el) {
506: return generateStandardLabel(el);
507: }
508:
509: public String getLabel(Version el) {
510: return generateStandardLabel(el);
511: }
512:
513: public String getLabel(WaitingTime el) {
514: return generateStandardLabel(el);
515: }
516:
517: public String getLabel(WorkflowProcess el) {
518: return generateStandardLabel(el);
519: }
520:
521: public String getLabel(WorkflowProcesses el) {
522: return generateStandardLabel(el);
523: }
524:
525: public String getLabel(WorkingTime el) {
526: return generateStandardLabel(el);
527: }
528:
529: public String getLabel(XPDLVersion el) {
530: return generateStandardLabel(el);
531: }
532:
533: public String getLabel(XMLEmptyChoiceElement el) {
534: return "";
535: }
536:
537: public String getLabel(XMLComplexChoice el) {
538: return settings.getLanguageDependentString(el.toName() + "Key");
539: }
540:
541: public String getLabel(XMLCollection el) {
542: return generateStandardLabel(el);
543: }
544:
545: public String getLabel(XMLCollectionElement el) {
546: return generateStandardLabel(el);
547: }
548:
549: public String getLabel(XMLComplexElement el) {
550: return generateStandardLabel(el);
551: }
552:
553: public String getLabel(XMLSimpleElement el) {
554: return generateStandardLabel(el);
555: }
556:
557: public String getLabel(XMLAttribute el) {
558: if (el.getParent() instanceof Join
559: || el.getParent() instanceof Split) {
560: return getLabel(el.getParent());
561: } else if (el.getParent() instanceof BasicType) {
562: return settings.getLanguageDependentString("SubTypeKey");
563: }
564: return generateStandardLabel(el);
565: }
566:
567: public String getLabel(XMLElement el) {
568:
569: try {
570: Class cl = el.getClass();
571: Method m = null;
572: try {
573: m = this .getClass().getMethod("getLabel",
574: new Class[] { cl });
575: } catch (Exception ex) {
576: if (!(cl == XMLSimpleElement.class
577: || cl == XMLAttribute.class
578: || cl == XMLComplexChoice.class
579: || cl == XMLComplexElement.class
580: || cl == XMLCollectionElement.class || cl == XMLCollection.class)) {
581: if (XMLComplexChoice.class.isAssignableFrom(cl)) {
582: cl = XMLComplexChoice.class;
583: } else if (XMLAttribute.class.isAssignableFrom(cl)) {
584: cl = XMLAttribute.class;
585: } else if (XMLSimpleElement.class
586: .isAssignableFrom(cl)) {
587: cl = XMLSimpleElement.class;
588: } else if (XMLComplexElement.class
589: .isAssignableFrom(cl)) {
590: cl = XMLComplexElement.class;
591: } else if (XMLCollection.class.isAssignableFrom(cl)) {
592: cl = XMLCollection.class;
593: }
594: }
595: }
596: m = this .getClass().getMethod("getLabel",
597: new Class[] { cl });
598: //System.err.println("calling "+m.toString());
599: return (String) m.invoke(this , new Object[] { el });
600: } catch (Throwable e) {
601: e.printStackTrace();
602: }
603:
604: return generateStandardLabel(el);
605: }
606:
607: public String generateStandardLabel(XMLElement el) {
608: return settings.getLanguageDependentString(el.toName() + "Key");
609: }
610:
611: public Settings getSettings() {
612: return settings;
613: }
614:
615: }
|