summaryrefslogtreecommitdiff
path: root/webapps/qooxdoo-0.6.3-sdk/frontend/api/source/class/api/ClassViewer.js
blob: 20e110b117bc84c97c310fa2363e763f4e5c3f3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
/*
#module(api)
*/

/**
 * Shows the class details.
 */
qx.OO.defineClass("api.ClassViewer", qx.ui.embed.HtmlEmbed,
function() {
  qx.ui.embed.HtmlEmbed.call(this);

  this.setOverflow("auto");
  this.setPadding(20);
  this.setEdge(0);
  this.setHtmlProperty("id", "ClassViewer");
  this.setVisibility(false);

  api.ClassViewer.instance = this;
});


qx.Proto._fixLinks = function(el)
{
  var a = el.getElementsByTagName("a");
  for (var i=0; i<a.length; i++)
  {
    if (typeof a[i].href == "string" && a[i].href.indexOf("http://") == 0) {
      a[i].target = "_blank";
    }
  }
}

/**
 * Initializes the content of the embedding DIV. Will be called by the
 * HtmlEmbed element initialization routine.
 */
qx.Proto._syncHtml = function() {
  var ClassViewer = api.ClassViewer;

  document._detailViewer = this;

  this._infoPanelHash = {};

  var html = "";

  // Add title
  html += '<h1></h1>';

  // Add description
  html += ClassViewer.DIV_START + ClassViewer.DIV_END;

  // Add constructor info
  html += this._createInfoPanel(ClassViewer.NODE_TYPE_CONSTRUCTOR,
    "constructor", "constructor", this._createMethodInfo,
    this._methodHasDetails, false, true);

  // Add properties info
  html += this._createInfoPanel(ClassViewer.NODE_TYPE_PROPERTY,
    "properties", "properties", this._createPropertyInfo,
    qx.util.Return.returnTrue, true, true);

  // Add event info
  html += this._createInfoPanel(ClassViewer.NODE_TYPE_EVENT,
    "events", "events", this._createEventInfo,
    this._eventHasDetails, true, true);

  // Add public methods info
  html += this._createInfoPanel(ClassViewer.NODE_TYPE_METHOD_PUBLIC,
    "methods-pub", "public methods", this._createMethodInfo,
    this._methodHasDetails, true, true);

  // Add protected methods info
  html += this._createInfoPanel(ClassViewer.NODE_TYPE_METHOD_PROTECTED,
    "methods-prot", "protected methods", this._createMethodInfo,
    this._methodHasDetails, true, false);

  // Add static public methods info
  html += this._createInfoPanel(ClassViewer.NODE_TYPE_METHOD_STATIC_PUBLIC,
    "methods-static-pub", "static public methods", this._createMethodInfo,
    this._methodHasDetails, false, true);

  // Add static protected methods info
  html += this._createInfoPanel(ClassViewer.NODE_TYPE_METHOD_STATIC_PROTECTED,
    "methods-static-prot", "static protected methods", this._createMethodInfo,
    this._methodHasDetails, false, false);

  // Add constants info
  html += this._createInfoPanel(ClassViewer.NODE_TYPE_CONSTANT,
    "constants", "constants", this._createConstantInfo,
    this._constantHasDetails, false, true);


  // Set the html
  // doc.body.innerHTML = html;
  this.getElement().innerHTML = html;
  this._fixLinks(this.getElement());

  // Extract the main elements
  var divArr = this.getElement().childNodes;
  this._titleElem = divArr[0];
  this._classDescElem = divArr[1];
  this._infoPanelHash[ClassViewer.NODE_TYPE_CONSTRUCTOR].infoElem             = divArr[2];
  this._infoPanelHash[ClassViewer.NODE_TYPE_PROPERTY].infoElem                = divArr[3];
  this._infoPanelHash[ClassViewer.NODE_TYPE_EVENT].infoElem                   = divArr[4];
  this._infoPanelHash[ClassViewer.NODE_TYPE_METHOD_PUBLIC].infoElem           = divArr[5];
  this._infoPanelHash[ClassViewer.NODE_TYPE_METHOD_PROTECTED].infoElem        = divArr[6];
  this._infoPanelHash[ClassViewer.NODE_TYPE_METHOD_STATIC_PUBLIC].infoElem    = divArr[7];
  this._infoPanelHash[ClassViewer.NODE_TYPE_METHOD_STATIC_PROTECTED].infoElem = divArr[8];
  this._infoPanelHash[ClassViewer.NODE_TYPE_CONSTANT].infoElem                = divArr[9];

  // Get the child elements
  for (var nodeType in this._infoPanelHash) {
    var typeInfo = this._infoPanelHash[nodeType];
    typeInfo.infoTitleElem = typeInfo.infoElem.firstChild;
    typeInfo.infoBodyElem = typeInfo.infoElem.lastChild;
  }

  // Update the view
  if (this._currentClassDocNode) {
    // NOTE: We have to set this._currentClassDocNode to null beore, because
    //       otherwise showClass thinks, there's nothing to do
    var classDocNode = this._currentClassDocNode;
    this._currentClassDocNode = null;
    this.showClass(classDocNode);
  }
}


/**
 * Creates an info panel. An info panel shows the information about one item
 * type (e.g. for public methods).
 *
 * @param nodeType {int} the node type to create the info panel for.
 * @param listName {string} the name of the node list in the class doc node where
 *        the items shown by this info panel are stored.
 * @param labelText {string} the label text describing the node type.
 * @param infoFactory {function} the factory method creating the HTML for one
 *        item.
 * @param hasDetailDecider {function} a function returning <code>true</code>
 *        when a item has details.
 * @param addInheritedCheckBox {boolean} whether to add a "show inherited ..."
 *        checkbox.
 * @param isOpen {boolean} whether the info panel is open by default.
 * @return {string} the HTML for the info panel.
 */
qx.Proto._createInfoPanel = function(nodeType, listName, labelText, infoFactory,
  hasDetailDecider, addInheritedCheckBox, isOpen)
{
  var uppercaseLabelText = labelText.charAt(0).toUpperCase() + labelText.substring(1);

  typeInfo = { listName:listName, labelText:labelText, infoFactory:infoFactory,
    hasDetailDecider:hasDetailDecider, isOpen:isOpen,
    hasInheritedCheckBox:addInheritedCheckBox }
  this._infoPanelHash[nodeType] = typeInfo;

  var html = '<div class="infoPanel"><h2>';

  if (addInheritedCheckBox) {
    html += '<span class="inheritCheck"><input type="checkbox" id="chk_' + nodeType + '" '
      + 'onclick="document._detailViewer._onInheritedCheckBoxClick(' + nodeType + ')"></input>'
      + '<label for="chk_' + nodeType + '">Show inherited</label></span>';
  }

  html += '<img class="openclose" src="'
    + qx.manager.object.AliasManager.getInstance().resolvePath('api/' + (isOpen ? 'close.gif' : 'open.gif')) + '"'
    + " onclick=\"document._detailViewer._onShowInfoPanelBodyClicked(" + nodeType + ")\"/> "
    + '<span '
    + " onclick=\"document._detailViewer._onShowInfoPanelBodyClicked(" + nodeType + ")\">"
    + uppercaseLabelText
    + '</span>';

  html += '</h2><div></div></div>';

  return html;
}


/**
 * Shows the information about a class.
 *
 * @param classNode {Map} the doc node of the class to show.
 */
qx.Proto.showClass = function(classNode) {
  if (this._currentClassDocNode == classNode) {
    // Nothing to do
    return;
  }

  this._currentClassDocNode = classNode;

  if (!this._titleElem) {
    // _initContentDocument was not called yet
    // -> Do nothing, the class will be shown in _initContentDocument.
    return;
  }

  var ClassViewer = api.ClassViewer;

  var titleHtml = "";

  titleHtml += '<div class="packageName">' + classNode.attributes.packageName + '</div>';

  titleHtml += '<span class="typeInfo">';

  if (classNode.attributes.isAbstract) {
    titleHtml += "Abstract ";
  } else if (classNode.attributes.isStatic) {
    titleHtml += "Static ";
  }

  titleHtml += "Class ";
  titleHtml += '</span>';
  titleHtml += classNode.attributes.name;

  this._titleElem.innerHTML = titleHtml;

  var classHtml = "";

   // Add the class description
  var ctorList = api.TreeUtil.getChild(classNode, "constructor");
  if (ctorList) {
    var desc = this._createDescHtml(ctorList.children[0], classNode, true);

    if (desc != "")
    {
      classHtml += '<div class="classDescription">' + desc + '</div>';
      classHtml += "<br/>";
    }
  }

  // Create the class hierarchy
  classHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Inheritance hierarchy:" + ClassViewer.DIV_END;

  var classHierarchy = [];
  var currClass = classNode;
  while (currClass != null) {
    classHierarchy.push(currClass);
    currClass = this._getClassDocNode(currClass.attributes.superClass);
  }
  this._currentClassHierarchy = classHierarchy;

  // Add the class hierarchy
  classHtml += ClassViewer.createImageHtml("api/class18.gif") + "Object<br/>";
  var indent = 0;
  for (var i = classHierarchy.length - 1; i >= 0; i--) {
    classHtml += ClassViewer.createImageHtml("api/nextlevel.gif", null, "margin-left:" + indent + "px")
      + ClassViewer.createImageHtml(api.TreeUtil.getIconUrl(classHierarchy[i]));
    if (i != 0) {
      classHtml += this._createItemLinkHtml(classHierarchy[i].attributes.fullName, null, false);
    } else {
      classHtml += classHierarchy[i].attributes.fullName;
    }
    classHtml += "<br/>";
    indent += 18;
  }

  classHtml += '<br/>';

  // Add child classes
  if (classNode.attributes.childClasses) {
    classHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Direct subclasses:" + ClassViewer.DIV_END
      + ClassViewer.DIV_START_DETAIL_TEXT;

    var classNameArr = classNode.attributes.childClasses.split(",");
    for (var i = 0; i < classNameArr.length; i++) {
      if (i != 0) {
        classHtml += ", ";
      }
      classHtml += this._createItemLinkHtml(classNameArr[i], null, true, false);
    }

    classHtml += ClassViewer.DIV_END;
    classHtml += '<br/>';
  }

  // Add @see attributes
  if (ctorList) {
    classHtml += this._createSeeAlsoHtml(ctorList.children[0], classNode);
    classHtml += '<br/>';
  }

  this._classDescElem.innerHTML = classHtml;
  this._fixLinks(this._classDescElem);

  // Refresh the info viewers
  for (var nodeType in this._infoPanelHash) {
    this._updateInfoPanel(parseInt(nodeType));
  }

  // Scroll to top
  this.getElement().scrollTop = 0;
}

qx.Proto.showInfo = function(classNode) {
  if (this._currentClassDocNode == classNode) {
    // Nothing to do
    return;
  }

  this._currentClassDocNode = classNode;

  if (!this._titleElem) {
    // _initContentDocument was not called yet
    // -> Do nothing, the class will be shown in _initContentDocument.
    return;
  }

  var ClassViewer = api.ClassViewer;

  this._titleElem.innerHTML = "Info View";
  this._classDescElem.innerHTML = "";

  // Scroll to top
  this.getElement().scrollTop = 0;
}

/**
 * Highlights an item (property, method or constant) and scrolls it visible.
 *
 * @param itemName {string} the name of the item to highlight.
 */
qx.Proto.showItem = function(itemName) {
  var itemNode = api.TreeUtil.getItemDocNode(this._currentClassDocNode, itemName);
  if (! itemNode) {
    alert("Item '" + itemName + "' not found");
  }

  var nodeType = this._getTypeForItemNode(itemNode);
  var elem = this._getItemElement(nodeType, itemNode.attributes.name).parentNode.parentNode;

  // Handle mark
  if (this._markedElement) {
    this._markedElement.className = "";
  }

  elem.className = "marked";
  this._markedElement = elem;

  // Scroll the element visible
  var top = qx.dom.Location.getPageBoxTop(elem);
  var height = elem.offsetHeight;

  var doc = this.getElement();
  var scrollTop = doc.scrollTop;
  var clientHeight = doc.offsetHeight;

  if (scrollTop > top) {
    doc.scrollTop = top;
  } else if (scrollTop < top + height - clientHeight) {
    doc.scrollTop = top + height - clientHeight;
  }
}


/**
 * Updates an info panel.
 *
 * @param nodeType {int} the node type of which to update the info panel.
 */
qx.Proto._updateInfoPanel = function(nodeType) {
  var ClassViewer = api.ClassViewer;

  var typeInfo = this._infoPanelHash[nodeType];

  // Get the nodes to show
  var nodeArr = null;
  var fromClassHash = null;
  if (typeInfo.isOpen && this._currentClassDocNode) {
    if (typeInfo.showInherited) {
      nodeArr = [];
      fromClassArr = [];
      fromClassHash = {};
      var currClassNode = this._currentClassDocNode;
      while (currClassNode != null) {
        var currParentNode = api.TreeUtil.getChild(currClassNode, typeInfo.listName);
        var currNodeArr = currParentNode ? currParentNode.children : null;
        if (currNodeArr) {
          // Add the nodes from this class
          for (var i = 0; i < currNodeArr.length; i++) {
            var name = currNodeArr[i].attributes.name;
            if (fromClassHash[name] == null) {
              fromClassHash[name] = currClassNode;
              nodeArr.push(currNodeArr[i]);
            }
          }
        }

        var superClassName = currClassNode.attributes.superClass;
        currClassNode = superClassName ? this._getClassDocNode(superClassName) : null;
      }

      // Sort the nodeArr by name
      nodeArr.sort(function(obj1, obj2) {
        return (obj1.attributes.name.toLowerCase() < obj2.attributes.name.toLowerCase()) ? -1 : 1;
      });
    } else {
      var parentNode = api.TreeUtil.getChild(this._currentClassDocNode, typeInfo.listName);
      nodeArr = parentNode ? parentNode.children : null;
    }
  }

  // Show the nodes
  if (nodeArr && nodeArr.length != 0)
  {
    var html = '<table cellspacing="0" cellpadding="0" class="info" width="100%">';

    for (var i = 0; i < nodeArr.length; i++)
    {
      var node = nodeArr[i];
      var fromClassNode = fromClassHash ? fromClassHash[node.attributes.name] : null;
      if (fromClassNode == null) {
        fromClassNode = this._currentClassDocNode;
      }

      var info = typeInfo.infoFactory.call(this, node, nodeType, fromClassNode, false);
      var inherited = fromClassNode && (fromClassNode != this._currentClassDocNode);
      var iconUrl = api.TreeUtil.getIconUrl(node, inherited);

      // Create the title row
      html += '<tr>';

        html += '<td class="icon">' + ClassViewer.createImageHtml(iconUrl) + '</td>';
        html += '<td class="type">' + ((info.typeHtml.length != 0) ? (info.typeHtml + "&nbsp;") : "") + '</td>';

        html += '<td class="toggle">';
        if (typeInfo.hasDetailDecider.call(this, node, nodeType, fromClassNode))
        {
          // This node has details -> Show the detail button
          html += '<img src="' + qx.manager.object.AliasManager.getInstance().resolvePath("api/open.gif") + '"'
            + " onclick=\"document._detailViewer._onShowItemDetailClicked(" + nodeType + ",'"
            + node.attributes.name + "'"
            + ((fromClassNode != this._currentClassDocNode) ? ",'" + fromClassNode.attributes.fullName + "'" : "")
            + ")\"/>";
        }
        else
        {
          html += "&#160;";
        }
        html += '</td>';

        html += '<td class="text">';

          // Create headline
          html += '<h3';

          if (typeInfo.hasDetailDecider.call(this, node, nodeType, fromClassNode))
          {
            html += " onclick=\"document._detailViewer._onShowItemDetailClicked(" + nodeType + ",'"
              + node.attributes.name + "'"
              + ((fromClassNode != this._currentClassDocNode) ? ",'" + fromClassNode.attributes.fullName + "'" : "")
              + ")\">";
          }
          else
          {
            html += '>';
          }

          html += info.titleHtml;
          html += '</h3>';

          // Create content area
          html += '<div _itemName="' + nodeArr[i].attributes.name + '">';
            html += info.textHtml;
          html += '</div>';

        html += '</td>';
      html += '</tr>';
    }

    html += '</table>';

    typeInfo.infoBodyElem.innerHTML = html;
    this._fixLinks(typeInfo.infoBodyElem);
    typeInfo.infoBodyElem.style.display = "";
  }
  else
  {
    if (typeInfo.isOpen)
    {
      typeInfo.infoBodyElem.innerHTML = '<div class="empty-info-body">This class has no ' + typeInfo.labelText + '</div>';
      typeInfo.infoBodyElem.style.display = "";
    }
    else
    {
      typeInfo.infoBodyElem.style.display = "none";
    }
  }
}


/**
 * Event handler. Called when the user clicked a button for showing/hiding the
 * details of an item.
 *
 * @param nodeType {int} the node type of the item to show/hide the details.
 * @param name {string} the name of the item.
 * @param fromClassName {string} the name of the class the item the item was
 *        defined in.
 */
qx.Proto._onShowItemDetailClicked = function(nodeType, name, fromClassName) {
  try {
    var typeInfo = this._infoPanelHash[nodeType];
    var textDiv = this._getItemElement(nodeType, name);

    if (!textDiv) {
      throw Error("Element for name '" + name + "' not found!");
    }

    var showDetails = textDiv._showDetails ? !textDiv._showDetails : true;
    textDiv._showDetails = showDetails;

    var fromClassNode = this._currentClassDocNode;
    if (fromClassName) {
      fromClassNode = this._getClassDocNode(fromClassName);
    }

    var listNode = api.TreeUtil.getChild(fromClassNode, typeInfo.listName);
    var node;
    if (nodeType == api.ClassViewer.NODE_TYPE_CONSTRUCTOR) {
      node = listNode.children[0];
    } else {
      node = api.TreeUtil.getChildByAttribute(listNode, "name", name);
    }

    // Update the close/open image
    var opencloseImgElem = textDiv.parentNode.previousSibling.firstChild;
    opencloseImgElem.src = qx.manager.object.AliasManager.getInstance().resolvePath(showDetails ? 'api/close.gif' : 'api/open.gif');

    // Update content
    var info = typeInfo.infoFactory.call(this, node, nodeType, fromClassNode, showDetails);
    textDiv.innerHTML = info.textHtml;
    this._fixLinks(textDiv);
  } catch (exc) {
    this.error("Toggling item details failed", exc);
  }
}


/**
 * Event handler. Called when the user clicked on a "show inherited ..."
 * checkbox.
 *
 * @param nodeType {int} the node type of which the inherited-checkbox was
 *        clicked.
 */
qx.Proto._onInheritedCheckBoxClick = function(nodeType) {
  try {
    var typeInfo = this._infoPanelHash[nodeType];
    var checkboxElem = typeInfo.infoTitleElem.getElementsByTagName("input")[0];

    typeInfo.showInherited = checkboxElem.checked;

    this._updateInfoPanel(nodeType);
  } catch (exc) {
    this.error("Handling inherited checkbox click failed", exc);
  }
}


/**
 * Event handler. Called when the user clicked a button for showing/hiding the
 * body of an info panel.
 *
 * @param nodeType {int} the node type of which the show/hide-body-button was
 *        clicked.
 */
qx.Proto._onShowInfoPanelBodyClicked = function(nodeType) {
  try {
    var typeInfo = this._infoPanelHash[nodeType];
    typeInfo.isOpen = !typeInfo.isOpen;

    var imgElem = typeInfo.infoTitleElem.getElementsByTagName("img")[0];
    imgElem.src = qx.manager.object.AliasManager.getInstance().resolvePath(typeInfo.isOpen ? 'api/close.gif' : 'api/open.gif');

    this._updateInfoPanel(nodeType);
  } catch (exc) {
    this.error("Toggling info body failed", exc);
  }
}


/**
 * Gets the HTML element showing the details of an item.
 *
 * @param nodeType {int} the node type of the item.
 * @param name {string} the item's name.
 * @return {Element} the HTML element showing the details of the item.
 */
qx.Proto._getItemElement = function(nodeType, name) {
  var typeInfo = this._infoPanelHash[nodeType];
  var elemArr = typeInfo.infoBodyElem.getElementsByTagName("TBODY")[0].childNodes;

  for (var i = 0; i < elemArr.length; i++) {
    // ARRG, should be implemented in a more fault-tolerant way
    // iterate over tr's, look inside the third "td" and there the second element
    if (elemArr[i].childNodes[3].childNodes[1].getAttribute("_itemName") == name) {
      return elemArr[i].childNodes[3].childNodes[1];
    }
  }
}


/**
 * Selects an item.
 *
 * @param itemName {string} the name of the item.
 * @see ApiViewer#selectItem
 */
qx.Proto._selectItem = function(itemName) {
  try {
    api.Viewer.instance.selectItem(itemName);
    qx.ui.core.Widget.flushGlobalQueues();
  } catch (exc) {
    this.error("Selecting item '" + itemName + "' failed", exc);
  }
}


/**
 * Gets the doc node of a class.
 *
 * @param className {string} the name of the class.
 * @return {Map} the doc node of the class.
 */
qx.Proto._getClassDocNode = function(className) {
  if (className) {
    return api.TreeUtil.getClassDocNode(api.Viewer.instance.getDocTree(), className);
  } else {
    return null;
  }
}


/**
 * Creates the HTML showing the information about a property.
 *
 * @param node {Map} the doc node of the property.
 * @param nodeType {int} the node type of the property.
 * @param fromClassNode {Map} the doc node of the class the property was defined.
 * @param showDetails {boolean} whether to show the details.
 * @return {string} the HTML showing the information about the property.
 */
qx.Proto._createPropertyInfo = function(node, nodeType, fromClassNode, showDetails) {
  var ClassViewer = api.ClassViewer;

  var info = {}

  var typeInfo = this._infoPanelHash[nodeType];

  // Get the property node that holds the documentation
  var docClassNode = fromClassNode;
  var docNode = node;
  if (node.attributes.docFrom) {
    docClassNode = this._getClassDocNode(node.attributes.docFrom);
    var listNode = api.TreeUtil.getChild(docClassNode, typeInfo.listName);
    docNode = api.TreeUtil.getChildByAttribute(listNode, "name", node.attributes.name);
  }

  // Add the title
  info.typeHtml = this._createTypeHtml(node, fromClassNode, "var");
  info.titleHtml = node.attributes.name;

  // Add the description
  info.textHtml = this._createDescHtml(docNode, fromClassNode, showDetails);

  if (showDetails) {
    // Add allowed values
    var allowedValue = null;
    if (node.attributes.possibleValues) {
      allowedValue = node.attributes.possibleValues;
    } else if (node.attributes.classname) {
      allowedValue = "instances of " + node.attributes.classname;
    } else if (node.attributes.instance) {
      allowedValue = "instances of " + node.attributes.instance + " or sub classes";
    } else if (node.attributes.unitDetection) {
      allowedValue = "units: " + node.attributes.unitDetection;
    } else if (node.attributes.type) {
      allowedValue = "any " + node.attributes.type;
    }

    if (allowedValue) {
      info.textHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Allowed values:" + ClassViewer.DIV_END
        + ClassViewer.DIV_START_DETAIL_TEXT;

      if (node.attributes.allowNull != "false") {
        info.textHtml += "null, ";
      }
      info.textHtml += allowedValue + ClassViewer.DIV_END;
    }

    // Add default value
    info.textHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Default value:" + ClassViewer.DIV_END
      + ClassViewer.DIV_START_DETAIL_TEXT
      + (node.attributes.defaultValue ? node.attributes.defaultValue : "null")
      + ClassViewer.DIV_END;

    // Add get alias
    if (node.attributes.getAlias) {
      info.textHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Get alias:" + ClassViewer.DIV_END
        + ClassViewer.DIV_START_DETAIL_TEXT + node.attributes.getAlias + ClassViewer.DIV_END;
    }

    // Add set alias
    if (node.attributes.setAlias) {
      info.textHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Set alias:" + ClassViewer.DIV_END
        + ClassViewer.DIV_START_DETAIL_TEXT + node.attributes.setAlias + ClassViewer.DIV_END;
    }

    // Add inherited from or overridden from
    if (fromClassNode && fromClassNode != this._currentClassDocNode) {
      info.textHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Inherited from:" + ClassViewer.DIV_END
        + ClassViewer.DIV_START_DETAIL_TEXT
        + this._createItemLinkHtml(fromClassNode.attributes.fullName)
        + ClassViewer.DIV_END;
    } else if (node.attributes.overriddenFrom) {
      info.textHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Overridden from:" + ClassViewer.DIV_END
        + ClassViewer.DIV_START_DETAIL_TEXT
        + this._createItemLinkHtml(node.attributes.overriddenFrom)
        + ClassViewer.DIV_END;
    }

    // Add @see attributes
    info.textHtml += this._createSeeAlsoHtml(docNode, docClassNode);

    // Add documentation errors
    info.textHtml += this._createErrorHtml(docNode, docClassNode);
  }

  return info;
}


/**
 * Checks whether an event has details.
 *
 * @param node {Map} the doc node of the event.
 * @param nodeType {int} the node type of the event.
 * @param fromClassNode {Map} the doc node of the class the event was defined.
 * @return {boolean} whether the event has details.
 */
qx.Proto._eventHasDetails = function(node, nodeType, fromClassNode) {
  return (fromClassNode != this._currentClassDocNode) // event is inherited
    || this._hasSeeAlsoHtml(node)
    || this._hasErrorHtml(node)
    || this._descHasDetails(node);
};


/**
 * Creates the HTML showing the information about an event.
 *
 * @param node {Map} the doc node of the event.
 * @param nodeType {int} the node type of the event.
 * @param fromClassNode {Map} the doc node of the class the event was defined.
 * @param showDetails {boolean} whether to show the details.
 * @return {string} the HTML showing the information about the event.
 */
qx.Proto._createEventInfo = function(node, nodeType, fromClassNode, showDetails) {
  var ClassViewer = api.ClassViewer;

  var info = {}

  var typeInfo = this._infoPanelHash[nodeType];

  // Add the title
  info.typeHtml = this._createTypeHtml(node, fromClassNode, "var");
  info.titleHtml = node.attributes.name;

  // Add the description
  info.textHtml = this._createDescHtml(node, fromClassNode, showDetails);

  if (showDetails) {
    // Add inherited from or overridden from
    if (fromClassNode && fromClassNode != this._currentClassDocNode) {
      info.textHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Inherited from:" + ClassViewer.DIV_END
        + ClassViewer.DIV_START_DETAIL_TEXT
        + this._createItemLinkHtml(fromClassNode.attributes.fullName)
        + ClassViewer.DIV_END;
    }

    // Add @see attributes
    info.textHtml += this._createSeeAlsoHtml(node, fromClassNode);

    // Add documentation errors
    info.textHtml += this._createErrorHtml(node, fromClassNode);
  }

  return info;
};


/**
 * Checks whether a method has details.
 *
 * @param node {Map} the doc node of the method.
 * @param nodeType {int} the node type of the method.
 * @param fromClassNode {Map} the doc node of the class the method was defined.
 * @return {boolean} whether the method has details.
 */
qx.Proto._methodHasDetails = function(node, nodeType, fromClassNode) {
  var TreeUtil = api.TreeUtil;

  var typeInfo = this._infoPanelHash[nodeType];

  // Get the method node that holds the documentation
  var docClassNode = fromClassNode;
  var docNode = node;
  if (node.attributes.docFrom) {
    docClassNode = this._getClassDocNode(node.attributes.docFrom);
    var listNode = TreeUtil.getChild(docClassNode, typeInfo.listName);
    docNode = TreeUtil.getChildByAttribute(listNode, "name", node.attributes.name);
  }

  // Check whether there are details
  var hasParams = TreeUtil.getChild(docNode, "params") != null;
  var hasReturn = TreeUtil.getChild(docNode, "return") != null;
  var isOverridden = fromClassNode != this._currentClassDocNode;

  return (fromClassNode != this._currentClassDocNode) // method is inherited
    || (node.attributes.overriddenFrom != null)       // method is overridden
    || (TreeUtil.getChild(docNode, "params") != null) // method has params
    || (TreeUtil.getChild(docNode, "return") != null) // method has return value
    || this._hasSeeAlsoHtml(docNode)
    || this._hasErrorHtml(docNode)
    || this._descHasDetails(docNode);
}


/**
 * Creates the HTML showing the information about a method.
 *
 * @param node {Map} the doc node of the method.
 * @param nodeType {int} the node type of the method.
 * @param fromClassNode {Map} the doc node of the class the method was defined.
 * @param showDetails {boolean} whether to show the details.
 * @return {string} the HTML showing the information about the method.
 */
qx.Proto._createMethodInfo = function(node, nodeType, fromClassNode, showDetails) {
  var ClassViewer = api.ClassViewer;
  var TreeUtil = api.TreeUtil;

  var info = {}

  var typeInfo = this._infoPanelHash[nodeType];

  // Get the method node that holds the documentation
  var docClassNode = fromClassNode;
  var docNode = node;
  if (node.attributes.docFrom) {
    docClassNode = this._getClassDocNode(node.attributes.docFrom);
    var listNode = TreeUtil.getChild(docClassNode, typeInfo.listName);
    docNode = TreeUtil.getChildByAttribute(listNode, "name", node.attributes.name);
  }

  if (node.attributes.isAbstract) {
    info.typeHtml = "abstract ";
  } else {
    info.typeHtml = "";
  }

  // Get name, icon and return type
  var returnNode = TreeUtil.getChild(docNode, "return");
  if (node.attributes.isCtor) {
    info.titleHtml = fromClassNode.attributes.name;
  } else {
    info.titleHtml = node.attributes.name;
    info.typeHtml += this._createTypeHtml(returnNode, fromClassNode, "void");
  }

  // Add the title (the method signature)
  info.titleHtml += '<span class="methodSignature"> <span class="parenthesis">(</span>';
  var paramsNode = TreeUtil.getChild(docNode, "params");
  if (paramsNode) {
    for (var i = 0; i < paramsNode.children.length; i++) {
      var param = paramsNode.children[i];
      if (i != 0) {
        info.titleHtml += '<span class="separator">,</span> ';
      }
      info.titleHtml += '<span class="parameterType">' + this._createTypeHtml(param, fromClassNode, "var") + "</span> "
        + param.attributes.name;
      if (param.attributes.defaultValue) {
        info.titleHtml += "?";
      }
    }
  }
  info.titleHtml += '<span class="parenthesis">)</span></span>';

  // Add the description
  if (node.attributes.isCtor) {
    info.textHtml = "Creates a new instance of " + fromClassNode.attributes.name + ".";
  } else {
    info.textHtml = this._createDescHtml(docNode, docClassNode, showDetails);
  }


  if (showDetails) {
    // Add Parameters
    var paramsNode = TreeUtil.getChild(docNode, "params");
    if (paramsNode) {
      info.textHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Parameters:" + ClassViewer.DIV_END;
      for (var i = 0; i < paramsNode.children.length; i++) {
        var param = paramsNode.children[i];
        var paramType = param.attributes.type ? param.attributes.type : "var";
        var dims = param.attributes.arrayDimensions;
        if (dims) {
          for (var i = 0; i < dims; i++) {
            paramType += "[]";
          }
        }
        var defaultValue = param.attributes.defaultValue;

        info.textHtml += ClassViewer.DIV_START_DETAIL_TEXT;
        if (defaultValue) {
          info.textHtml += ClassViewer.SPAN_START_OPTIONAL;
        }
        info.textHtml += ClassViewer.SPAN_START_PARAM_NAME + param.attributes.name + ClassViewer.SPAN_END;
        if (defaultValue) {
          info.textHtml += " (default: " + defaultValue + ") " + ClassViewer.SPAN_END;
        }

        var paramDescNode = TreeUtil.getChild(param, "desc");
        if (paramDescNode) {
          info.textHtml += " " + this._createDescriptionHtml(paramDescNode.attributes.text, docClassNode);
        }
        info.textHtml += ClassViewer.DIV_END;
      }
    }

    // Add return value
    if (returnNode) {
      var returnDescNode = TreeUtil.getChild(returnNode, "desc");
      if (returnDescNode) {
        info.textHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Returns:" + ClassViewer.DIV_END
          + ClassViewer.DIV_START_DETAIL_TEXT
          + this._createDescriptionHtml(returnDescNode.attributes.text, docClassNode)
          + ClassViewer.DIV_END;
      }
    }

    // Add inherited from or overridden from
    if (fromClassNode && fromClassNode != this._currentClassDocNode) {
      info.textHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Inherited from:" + ClassViewer.DIV_END
        + ClassViewer.DIV_START_DETAIL_TEXT
        + this._createItemLinkHtml(fromClassNode.attributes.fullName)
        + ClassViewer.DIV_END;
    } else if (node.attributes.overriddenFrom) {
      info.textHtml += ClassViewer.DIV_START_DETAIL_HEADLINE + "Overridden from:" + ClassViewer.DIV_END
        + ClassViewer.DIV_START_DETAIL_TEXT
        + this._createItemLinkHtml(node.attributes.overriddenFrom)
        + ClassViewer.DIV_END;
    }

    // Add @see attributes
    info.textHtml += this._createSeeAlsoHtml(docNode, docClassNode);

    // Add documentation errors
    info.textHtml += this._createErrorHtml(docNode, docClassNode);
  }

  return info;
}


/**
 * Checks whether a constant has details.
 *
 * @param node {Map} the doc node of the constant.
 * @param nodeType {int} the node type of the constant.
 * @param fromClassNode {Map} the doc node of the class the constant was defined.
 * @return {boolean} whether the constant has details.
 */
qx.Proto._constantHasDetails = function(node, nodeType, fromClassNode) {
  return this._hasSeeAlsoHtml(node) || this._hasErrorHtml(node) || this._descHasDetails(node);
}


/**
 * Creates the HTML showing the information about a constant.
 *
 * @param node {Map} the doc node of the constant.
 * @param nodeType {int} the node type of the constant.
 * @param fromClassNode {Map} the doc node of the class the constant was defined.
 * @param showDetails {boolean} whether to show the details.
 * @return {string} the HTML showing the information about the constant.
 */
qx.Proto._createConstantInfo = function(node, nodeType, fromClassNode, showDetails) {
  var info = {}

  // Add the title
  info.typeHtml = this._createTypeHtml(node, fromClassNode, "var");
  info.titleHtml = node.attributes.name;

  // Add the description
  info.textHtml = this._createDescHtml(node, fromClassNode, showDetails);

  if (showDetails) {
    // Add @see attributes
    info.textHtml += this._createSeeAlsoHtml(node, fromClassNode);

    // Add documentation errors
    info.textHtml += this._createErrorHtml(node, fromClassNode);
  }

  return info;
}


/**
 * Returns whether the description of an item has details (has more than one
 * sentence).
 *
 * @param node {Map} the doc node of the item.
 * @return {boolean} whether the description of an item has details.
 */
qx.Proto._descHasDetails = function(node) {
  var descNode = api.TreeUtil.getChild(node, "desc");
  if (descNode) {
    var desc = descNode.attributes.text;
    return this._extractFirstSentence(desc) != desc;
  } else {
    return false;
  }
}


/**
 * Creates the HTML showing the description of an item.
 *
 * @param node {Map} the doc node of the item.
 * @param fromClassNode {Map} the doc node of the class the item was defined.
 * @param showDetails {boolean} whether to show details. If <code>false</code>
 *        only the first sentence of the description will be shown.
 * @return {string} the HTML showing the description.
 */
qx.Proto._createDescHtml = function(node, fromClassNode, showDetails) {
  var descNode = api.TreeUtil.getChild(node, "desc");
  if (descNode) {
    var desc = descNode.attributes.text;
    if (!showDetails) {
      desc = this._extractFirstSentence(desc);
    }
    return api.ClassViewer.DIV_START_DESC
      + this._createDescriptionHtml(desc, fromClassNode)
      + api.ClassViewer.DIV_END;
  } else {
    return "";
  }
}


/**
 * Extracts the first sentence from a text.
 *
 * @param text {string} the text.
 * @return {string} the first sentence from the text.
 */
qx.Proto._extractFirstSentence = function(text)
{
  var ret = text;

  // Extract first block
  var pos = ret.indexOf("</p>");
  if (pos != -1)
  {
    ret = ret.substr(0, pos+4);

    var hit = api.ClassViewer.SENTENCE_END_REGEX.exec(ret);
    if (hit != null) {
      ret = text.substring(0, hit.index + hit[0].length - 1) + "</p>";
    }
  }

  return ret;
}


/**
 * Checks whether a item has &#64;see attributes.
 *
 * @param node {Map} the doc node of the item.
 * @return {boolean} whether the item has &#64;see attributes.
 */
qx.Proto._hasSeeAlsoHtml = function(node) {
  var TreeUtil = api.TreeUtil;

  var descNode = TreeUtil.getChild(node, "desc");
  if (descNode) {
    var attributesNode = TreeUtil.getChild(descNode, "attributes");
    if (attributesNode) {
      var seeAttribNode = TreeUtil.getChildByAttribute(attributesNode, "name", "see");
      if (seeAttribNode) {
        return true;
      }
    }
  }

  // There is no @see attribute
  return false;
}


/**
 * Creates the HTML showing the &#64;see attributes of an item.
 *
 * @param node {Map} the doc node of the item.
 * @param fromClassNode {Map} the doc node of the class the item was defined.
 * @return {string} the HTML showing the &#64;see attributes.
 */
qx.Proto._createSeeAlsoHtml = function(node, fromClassNode) {
  var ClassViewer = api.ClassViewer;

  var descNode = api.TreeUtil.getChild(node, "desc");
  if (descNode) {
    var attributesNode = api.TreeUtil.getChild(descNode, "attributes");
    if (attributesNode) {
      var seeAlsoHtml = "";
      for (var i = 0; i < attributesNode.children.length; i++) {
        var attribNode = attributesNode.children[i];
        if (attribNode.attributes.name == "see") {
          // This is a @see attribute
          if (seeAlsoHtml.length != 0) {
            seeAlsoHtml += ", ";
          }
          seeAlsoHtml += this._createItemLinkHtml(attribNode.attributes.text, fromClassNode);
        }
      }

      if (seeAlsoHtml.length != 0) {
        // We had @see attributes
        return ClassViewer.DIV_START_DETAIL_HEADLINE + "See also:" + ClassViewer.DIV_END
          + ClassViewer.DIV_START_DETAIL_TEXT + seeAlsoHtml + ClassViewer.DIV_END;
      }
    }
  }

  // Nothing found
  return "";
}


/**
 * Checks whether a item has documentation errors.
 *
 * @param node {Map} the doc node of the item.
 * @return {boolean} whether the item has documentation errors.
 */
qx.Proto._hasErrorHtml = function(node) {
  var errorNode = api.TreeUtil.getChild(node, "errors");
  return (errorNode != null);
}


/**
 * Creates the HTML showing the documentation errors of an item.
 *
 * @param node {Map} the doc node of the item.
 * @param fromClassNode {Map} the doc node of the class the item was defined.
 * @return {string} the HTML showing the documentation errors.
 */
qx.Proto._createErrorHtml = function(node, fromClassNode) {
  var ClassViewer = api.ClassViewer;

  var errorNode = api.TreeUtil.getChild(node, "errors");
  if (errorNode) {
    var html = ClassViewer.DIV_START_ERROR_HEADLINE + "Documentation errors:" + ClassViewer.DIV_END;
    var errArr = errorNode.children;
    for (var i = 0; i < errArr.length; i++) {
      html += ClassViewer.DIV_START_DETAIL_TEXT + errArr[i].attributes.msg + " <br/>";
      html += "("
      if (fromClassNode && fromClassNode != this._currentClassDocNode) {
        html += fromClassNode.attributes.fullName + "; ";
      }
      html += "Line: " + errArr[i].attributes.line + ", Column:" + errArr[i].attributes.column + ")" + ClassViewer.DIV_END;
    }
    return html;
  } else {
    return "";
  }
}


/**
 * Creates the HTML showing the type of a doc node.
 *
 * @param typeNode {Map} the doc node to show the type for.
 * @param packageBaseClass {Map} the doc node of the class <code>typeNode</code>
 *        belongs to.
 * @param defaultType {string} the type name to use if <code>typeNode</code> is
 *        <code>null</code> or defines no type.
 * @param useShortName {boolean,true} whether to use short class names
 *        (without package).
 * @return {string} the HTML showing the type.
 */
qx.Proto._createTypeHtml = function(typeNode, packageBaseClass, defaultType, useShortName) {
  if (useShortName == null) {
    useShortName = true;
  }

  var types = [];
  var typeHtml, typeDimensions, typeName, linkText, dims;

  if (typeNode)
  {
    // read in children
    if (typeNode.children && api.TreeUtil.getChild(typeNode, "types"))
    {
      for (var i=0, a=api.TreeUtil.getChild(typeNode, "types").children, l=a.length; i<l; i++)
      {
        if (a[i].type == "entry")
        {
          types.push(a[i].attributes);
        }
      }
    }

    // read from attributes (alternative)
    if (types.length == 0 && typeNode.attributes)
    {
      typeName = typeNode.attributes.instance ? typeNode.attributes.instance : typeNode.attributes.type;

      if (typeName != undefined)
      {
        dims = typeNode.attributes.dimensions;

        if (typeof dims == "number" && dims > 0) {
          types.push({ "type" : typeName, "dimensions" : dims });
        } else {
          types.push({ "type" : typeName });
        }
      }
    }
  }

  if (types.length == 0)
  {
    typeHtml = defaultType;
  }
  else
  {
    typeHtml = "";

    if (types.length > 1) {
      typeHtml += "("
    }

    for (var j=0; j<types.length; j++)
    {
      if (j>0) {
        typeHtml += " | ";
      }

      typeName = types[j].type;
      typeDimensions = types[j].dimensions;

      if (api.ClassViewer.PRIMITIVES[typeName])
      {
        typeHtml += typeName;
      }
      else
      {
        linkText = typeName;
        if (useShortName)
        {
          var lastDot = typeName.lastIndexOf(".");
          if (lastDot != -1) {
            linkText += " " + typeName.substring(lastDot + 1);
          }
        }
        typeHtml += this._createItemLinkHtml(linkText, packageBaseClass, false, true);
      }

      if (typeDimensions)
      {
        for (var i = 0; i < parseInt(typeDimensions); i++) {
          typeHtml += "[]";
        }
      }
    }

    if (types.length > 1) {
      typeHtml += ")"
    }
  }

  return typeHtml;
}


/**
 * Creates HTML that replaces all &#64;link-attributes with links.
 *
 * @param description {string} the description.
 * @param packageBaseClass {Map,null} the doc node of the class to use for
 *        auto-adding packages.
 */
qx.Proto._createDescriptionHtml = function(description, packageBaseClass) {
  var linkRegex = /\{@link([^\}]*)\}/mg;

  var html = "";
  var hit;
  var lastPos = 0;
  while ((hit = linkRegex.exec(description)) != null) {
    // Add the text before the link
    html += description.substring(lastPos, hit.index)
      + this._createItemLinkHtml(hit[1], packageBaseClass);

    lastPos = hit.index + hit[0].length;
  }

  // Add the text after the last hit
  html += description.substring(lastPos, description.length);

  return html;
}


/**
 * Creates the HTML for a link to an item.
 *
 * @param linkText {string} the link text
 *        (e.g. "mypackage.MyClass#myMethod alt text")
 * @param packageBaseClass {Map,null} the doc node of the class to use when
 *        auto-adding the package to a class name having no package specified.
 *        If null, no automatic package addition is done.
 * @param useIcon {boolean,true} whether to add an icon to the link.
 * @param useShortName {boolean,false} whether to use the short name.
 */
qx.Proto._createItemLinkHtml = function(linkText, packageBaseClass, useIcon,
  useShortName)
{
  if (useIcon == null) {
    useIcon = true;
  }

  linkText = qx.lang.String.trim(linkText);

  if (linkText.charAt(0) == '"' || linkText.charAt(0) == '<') {
    // This is a String or a link to a URL -> Just use it as it is
    return linkText;
  } else {
    // This is a link to another class or method -> Create an item link

    // Separate item name from label
    var hit = api.ClassViewer.ITEM_SPEC_REGEX.exec(linkText);
    if (hit == null) {
      // Malformed item name
      return linkText;
    } else {
      var className = hit[2];
      var itemName = hit[3];
      var label = hit[6];

      // Make the item name absolute
      if (className == null || className.length == 0) {
        // This is a relative link to a method -> Add the current class
        className = packageBaseClass.attributes.fullName;
      } else if (packageBaseClass && className.indexOf(".") == -1) {
        // The class name has no package -> Use the same package as the current class
        var name = packageBaseClass.attributes.name;
        var fullName = packageBaseClass.attributes.fullName;
        var packageName = fullName.substring(0, fullName.length - name.length);
        className = packageName + className;
      }

      // Get the node info
      if (label == null || label.length == 0) {
        // We have no label -> Use the item name as label
        label = hit[1];
      }

      // Add the right icon
      if (useIcon) {
        var classNode = this._getClassDocNode(className);
        if (classNode) {
          var itemNode;
          if (itemName) {
            // The links points to a item of the class
            var cleanItemName = itemName.substring(1);
            var parenPos = cleanItemName.indexOf("(");
            if (parenPos != -1) {
              cleanItemName = qx.lang.String.trim(cleanItemName.substring(0, parenPos));
            }
            itemNode = api.TreeUtil.getItemDocNode(classNode, cleanItemName);
          } else {
            // The links points to the class
            itemNode = classNode;
          }
          if (itemNode) {
            var iconUrl = api.TreeUtil.getIconUrl(itemNode);
            var iconCode = api.ClassViewer.createImageHtml(iconUrl);
          }
        }
      }

      // Create a real bookmarkable link
      // NOTE: The onclick-handler must be added by HTML code. If it
      //       is added using the DOM element then the href is followed.
      var fullItemName = className + (itemName ? itemName : "");
      return (typeof iconCode != "undefined" ? iconCode : "")
        + '<a href="' + window.location.protocol + '//' +  window.location.pathname
        + '#' + fullItemName + '" onclick="'
        + 'document._detailViewer._selectItem(\'' + fullItemName + '\'); return false;"'
        + ' title="' + fullItemName + '">' + label + '</a>';
    }
  }
}


/**
 * Gets the node type for a doc node.
 *
 * @param itemNode {Map} the doc node of the item.
 * @return {int} the item's node type.
 */
qx.Proto._getTypeForItemNode = function(itemNode) {
  var ClassViewer = api.ClassViewer;

  if (itemNode.type == "constant") {
    return ClassViewer.NODE_TYPE_CONSTANT;
  } else if (itemNode.type == "property") {
    return ClassViewer.NODE_TYPE_PROPERTY;
  } else if (itemNode.type == "event") {
    return ClassViewer.NODE_TYPE_EVENT;
  } else if (itemNode.type == "method") {
    var name = itemNode.attributes.name;
    if (name == null) {
      return ClassViewer.NODE_TYPE_CONSTRUCTOR;
    } else if (name.charAt(0) == "_") {
      if (itemNode.attributes.isStatic) {
        return ClassViewer.NODE_TYPE_METHOD_STATIC_PROTECTED;
      } else {
        return ClassViewer.NODE_TYPE_METHOD_PROTECTED;
      }
    } else {
      if (itemNode.attributes.isStatic) {
        return ClassViewer.NODE_TYPE_METHOD_STATIC_PUBLIC;
      } else {
        return ClassViewer.NODE_TYPE_METHOD_PUBLIC;
      }
    }
  }
}


// overridden
qx.Proto.dispose = function() {
  if (this.getDisposed()) {
    return;
  }

  this._titleElem = null;
  this._classDescElem = null;
  this._markedElement = null;

  for (var nodeType in this._infoPanelHash) {
    this._infoPanelHash[nodeType].infoElem = null;
    this._infoPanelHash[nodeType].infoTitleElem = null;
    this._infoPanelHash[nodeType].infoBodyElem = null;
  }

  document._detailViewer = null;

  return qx.ui.embed.HtmlEmbed.prototype.dispose.call(this);
}


/** {Map} The primitive types. These types will not be shown with links. */
qx.Class.PRIMITIVES = { "boolean":true, "string":true, "float":true,
  "number":true, "int":true, "double":true, "var":true, "void":true,
  "RegExp":true, "Array":true, "Map":true, "Date":true, "Element":true,
  "Node":true, "Function":true, "Object":true, "Event":true };

/**
 * {regexp} The regexp for parsing a item name
 * (e.g. "mypackage.MyClass#MY_CONSTANT alternative text").
 */
qx.Class.ITEM_SPEC_REGEX = /^(([\w\.]+)?(#\w+(\([^\)]*\))?)?)(\s+(.*))?$/;

/** {regexp} The regexp that finds the end of a sentence. */
qx.Class.SENTENCE_END_REGEX = /[^\.].\.(\s|<)/;


/** {int} The node type of a constructor. */
qx.Class.NODE_TYPE_CONSTRUCTOR = 1;
/** {int} The node type of a property. */
qx.Class.NODE_TYPE_PROPERTY = 2;
/** {int} The node type of an event. */
qx.Class.NODE_TYPE_EVENT = 3;
/** {int} The node type of a public method. */
qx.Class.NODE_TYPE_METHOD_PUBLIC = 4;
/** {int} The node type of a protected method. */
qx.Class.NODE_TYPE_METHOD_PROTECTED = 5;
/** {int} The node type of a static public method. */
qx.Class.NODE_TYPE_METHOD_STATIC_PUBLIC = 6;
/** {int} The node type of a static protected method. */
qx.Class.NODE_TYPE_METHOD_STATIC_PROTECTED = 7;
/** {int} The node type of a constant. */
qx.Class.NODE_TYPE_CONSTANT = 8;

/** {string} The start tag of a div. */
qx.Class.DIV_START = '<div>';
/** {string} The start tag of a div containing an item description. */
qx.Class.DIV_START_DESC = '<div class="item-desc">';
/** {string} The start tag of a div containing the headline of an item detail. */
qx.Class.DIV_START_DETAIL_HEADLINE = '<div class="item-detail-headline">';
/** {string} The start tag of a div containing the text of an item detail. */
qx.Class.DIV_START_DETAIL_TEXT = '<div class="item-detail-text">';
/** {string} The start tag of a div containing the headline of an item error. */
qx.Class.DIV_START_ERROR_HEADLINE = '<div class="item-detail-error">';
/** {string} The end tag of a div. */
qx.Class.DIV_END = '</div>';

/** {string} The start tag of a span containing an optional detail. */
qx.Class.SPAN_START_OPTIONAL = '<span class="item-detail-optional">';
/** {string} The start tag of a span containing a parameter name. */
qx.Class.SPAN_START_PARAM_NAME = '<span class="item-detail-param-name">';
/** {string} The end tag of a span. */
qx.Class.SPAN_END = '</span>';


/**
 * Creates the HTML showing an image.
 *
 * @param imgUrl {var} the URL of the image. May be a string or an array of
 *        strings (for overlay images).
 * @param tooltip {string} the tooltip to show.
 * @param styleAttributes {string} the style attributes to add to the image.
 */
qx.Class.createImageHtml = function(imgUrl, tooltip, styleAttributes) {
  if (typeof imgUrl == "string") {
    return '<img src="' + qx.manager.object.AliasManager.getInstance().resolvePath(imgUrl) + '" class="img"'
      + (styleAttributes ? ' style="' + styleAttributes + '"' : "") + '/>';
  } else {
    if (styleAttributes) {
      styleAttributes += ";vertical-align:top";
    } else {
      styleAttributes = "vertical-align:top";
    }
    return api.ClassViewer.createOverlayImageHtml(18, 18, imgUrl, tooltip, styleAttributes);
  }
}


/**
 * Creates HTML that shows an overlay image (several images on top of each other).
 * The resulting HTML will behave inline.
 *
 * @param width {int} the width of the images.
 * @param height {int} the height of the images.
 * @param imgUrlArr {string[]} the URLs of the images. The last image will be
 *        painted on top.
 * @param toolTip {string,null} the tooltip of the icon.
 * @param styleAttributes {string,null} custom CSS style attributes.
 * @return {string} the HTML with the overlay image.
 */
qx.Class.createOverlayImageHtml
  = function(width, height, imgUrlArr, toolTip, styleAttributes)
{
  var html = '<div style="position:relative;top:0;left:0;width:' + width + 'px;height:' + height + 'px'
  + ((styleAttributes == null) ? '' : (';' + styleAttributes)) + '">';

  for (var i = 0; i < imgUrlArr.length; i++) {
    html += '<img';
    if (toolTip != null) {
      html += ' title="' + toolTip + '"';
    }
    html += ' style="position:absolute;top:0px;left:0px" src="' + qx.manager.object.AliasManager.getInstance().resolvePath(imgUrlArr[i]) + '"/>';
  }

  html += '</div>';

  /*
  // NOTE: See testOverlay.html
  var html = '<table cellpadding="0" cellspacing="0" '
    + 'style="display:inline;position:relative;border:1px solid blue'
    + ((styleAttributes == null) ? '' : (';' + styleAttributes)) + '"><tr>'
    + '<td style="width:' + width + 'px;height:' + height + 'px">';
  for (var i = 0; i < imgUrlArr.length; i++) {
    html += '<img';
    if (toolTip != null) {
      html += ' title="' + toolTip + '"';
    }
    html += ' style="position:absolute;top:0px;left:0px" src="' + imgUrlArr[i] + '"></img>';
  }
  html += '</td></tr></table>';
  */

  return html;
}