@@ -279,37 +279,6 @@ ClassView.prototype.filterInherits = function (data) {
279279 "%DataType" : true
280280 } ;
281281
282- // inheritance: { "ClassName": { "IHCN": 1, ... }, ... }
283- // inherit isDataType & classType if not set for inherited classes
284- //var rec = function (className) {
285- // if (!(cls = data.classes[className])) return { isDataType: null, classType: null };
286- // var c, res = { isDataType: cls.isDataType || null, classType: cls.classType || null}, resi, cls;
287- // if (className === "%DeepSee.ListingTable") console.log("-------", res);
288- // if (data.inheritance[className]) {
289- // for (c in data.inheritance[className]) {
290- // resi = undefined;
291- // if (data.classes[c]) {
292- // if (data.classes[c].isDataType) resi = {
293- // isDataType: data.classes[c].isDataType,
294- // classType: data.classes[c].classType || null
295- // }; else if (data.classes[c].classType) {
296- // res.classType = data.classes[c].classType;
297- // }
298- // }
299- // if (!resi) resi = rec(c);
300- // if (className === "Aviation.Cubes.Aircraft.Listing") console.log(c, resi);
301- // if (res.isDataType === null) { res.isDataType = resi.isDataType; }
302- // if (res.classType === null) { res.classType = resi.classType; }
303- // }
304- // }
305- // if (res.isDataType !== null && !cls.isDataType) { cls.isDataType = res.isDataType; }
306- // if (res.classType !== null && !cls.classType) { cls.classType = res.classType; }
307- // return res;
308- //};
309- //for (p1 in data.classes) {
310- // rec(p1);
311- //}
312-
313282 var f = function ( p ) {
314283 return filter . hasOwnProperty ( p ) || ( data . classes [ p ] || { } ) [ "isDataType" ] ||
315284 lib . obj ( ( ( data . classes [ p ] || { } ) . super || "" ) . split ( "," ) ) . hasOwnProperty ( "%DataType" ) ;
@@ -341,33 +310,6 @@ ClassView.prototype.getClassSigns = function (classMetaData) {
341310
342311 var signs = [ ] , ct ;
343312
344- // todo: preprocess class type before diagram load
345- //if (classMetaData["classType"] || sup) {
346- // ct = classMetaData["classType"];
347- // if (sup.hasOwnProperty("%Library.Persistent") || sup.hasOwnProperty("%Persistent")) {
348- // ct = "Persistent";
349- // }
350- // if (sup.hasOwnProperty("%Library.SerialObject") || sup.hasOwnProperty("%SerialObject")) {
351- // ct = "Serial";
352- // }
353- // if (
354- // sup.hasOwnProperty("%Library.RegisteredObject")
355- // || sup.hasOwnProperty("%RegisteredObject")
356- // ) {
357- // ct = "Registered";
358- // }
359- // if (sup.hasOwnProperty("%Library.DataType") || sup.hasOwnProperty("%DataType")) {
360- // ct = "Datatype";
361- // }
362- // if (ct) {
363- // CT = ct;
364- // signs.push({
365- // icon: lib.image.greenPill,
366- // text: lib.capitalize(ct),
367- // textStyle: "fill:rgb(130,0,255)"
368- // });
369- // }
370- //}
371313 if ( ct = classMetaData [ "$classType" ] ) {
372314 if ( ct !== "Serial" && ct !== "Registered" && ct !== "Persistent" && ct !== "DataType" ) {
373315 signs . push ( {
@@ -459,6 +401,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
459401 keyWordsArray . push ( n ) ;
460402 arr . push ( {
461403 text : n + ( params [ n ] [ "Type" ] ? ": " + params [ n ] [ "Type" ] : "" ) ,
404+ hover : params [ n ] [ "Description" ] || "" ,
462405 icons : self . getPropertyIcons ( params [ n ] )
463406 } ) ;
464407 }
@@ -470,6 +413,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
470413 keyWordsArray . push ( n ) ;
471414 arr . push ( {
472415 text : n + ( ps [ n ] [ "Type" ] ? ": " + ps [ n ] [ "Type" ] : "" ) ,
416+ hover : ps [ n ] [ "Description" ] || "" ,
473417 icons : self . getPropertyIcons ( ps [ n ] )
474418 } ) ;
475419 }
@@ -487,6 +431,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
487431 clickHandler : ( function ( n ) {
488432 return function ( ) { self . showMethodCode ( name , n ) ; }
489433 } ) ( n ) ,
434+ hover : met [ n ] [ "Description" ] || "" ,
490435 icons : self . getPropertyIcons ( met [ n ] )
491436 } ) ;
492437 }
@@ -499,7 +444,10 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
499444 arr . push ( {
500445 text : n ,
501446 icons : self . getPropertyIcons ( qrs [ n ] ) ,
502- hover : qrs [ n ] [ "SqlQuery" ]
447+ hover : qrs [ n ] [ "SqlQuery" ] ,
448+ clickHandler : ( function ( q , className ) {
449+ return function ( ) { self . showQuery ( className , q ) ; }
450+ } ) ( qrs [ n ] , name )
503451 } ) ;
504452 }
505453 return arr ;
@@ -519,26 +467,58 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
519467
520468ClassView . prototype . showMethodCode = function ( className , methodName ) {
521469
522- var self = this ,
523- els = this . cacheUMLExplorer . elements ;
470+ var self = this ;
524471
525472 this . cacheUMLExplorer . source . getMethod ( className , methodName , function ( err , data ) {
526473 if ( err || data . error ) {
527474 self . cacheUMLExplorer . UI . displayMessage ( "Unable to get method \"" + methodName + "\"!" ) ;
528475 return ;
529476 }
530- els . methodLabel . textContent = className + ": " + methodName + "("
477+ self . showPanel ( {
478+ header : className + ": " + methodName + "("
531479 + ( data [ "arguments" ] || "" ) . replace ( / , / g, ", " ) . replace ( / : / g, ": " ) + ")"
532- + ( data [ "returns" ] ? ": " + data [ "returns" ] : "" ) ;
533- els . methodDescription . innerHTML = data [ "description" ] || "" ;
534- els . methodCode . innerHTML = lib . highlightCOS ( data [ "code" ] || "" ) ;
535- els . methodViewBounds . style . height =
536- els . classView . offsetHeight - els . methodViewBounds . offsetTop + "px" ;
537- els . methodCodeView . classList . add ( "active" ) ;
480+ + ( data [ "returns" ] ? ": " + data [ "returns" ] : "" ) ,
481+ comment : data [ "description" ] ,
482+ body : lib . highlightCOS ( data [ "code" ] || "" )
483+ } ) ;
484+ } ) ;
485+
486+ } ;
487+
488+ ClassView . prototype . showQuery = function ( className , queryData ) {
489+
490+ queryData = queryData || { } ;
491+
492+ this . showPanel ( {
493+ header : "##class(" + className + ")." + queryData [ "Name" ] + "("
494+ + ( queryData [ "FormalSpec" ] || "" ) . replace ( / , / g, ", " ) . replace ( / : / g, ": " ) + ")" ,
495+ comment : queryData [ "Description" ] ,
496+ body : lib . highlightSQL ( queryData [ "SqlQuery" ] || "" )
538497 } ) ;
539498
540499} ;
541500
501+ /**
502+ * Show panel filled with given HTML contents.
503+ * @param {string } data.header
504+ * @param {string } [data.comment]
505+ * @param {string } data.body
506+ */
507+ ClassView . prototype . showPanel = function ( data ) {
508+
509+ var els = this . cacheUMLExplorer . elements ;
510+
511+ data = data || { } ;
512+
513+ els . methodLabel . textContent = data . header || "" ;
514+ els . methodDescription . innerHTML = data . comment || "" ;
515+ els . methodCode . innerHTML = data . body || "" ;
516+ els . methodViewBounds . style . height =
517+ els . classView . offsetHeight - els . methodViewBounds . offsetTop + "px" ;
518+ els . methodCodeView . classList . add ( "active" ) ;
519+
520+ } ;
521+
542522ClassView . prototype . hideMethodCode = function ( ) {
543523
544524 this . cacheUMLExplorer . elements . methodCodeView . classList . remove ( "active" ) ;
@@ -870,7 +850,8 @@ ClassView.prototype.init = function () {
870850 this . graph . on ( "change:position" , function ( object ) {
871851 if ( _ . contains ( self . objects , object ) )
872852 for ( p in self . links ) {
873- self . paper . findViewByModel ( self . links [ p ] ) . update ( ) ;
853+ var link = self . paper . findViewByModel ( self . links [ p ] ) ;
854+ if ( link ) link . update ( ) ; // removed links, should be in todo
874855 }
875856 } ) ;
876857
@@ -955,13 +936,18 @@ ClassView.prototype.init = function () {
955936ClassView . prototype . onRendered = function ( ) {
956937
957938 [ ] . slice . call ( document . querySelectorAll ( ".line-hoverable" ) ) . forEach ( function ( el ) {
958- var hm = new HoverMessage ( el . getAttribute ( "hovertext" ) ) ;
939+ var hm = new HoverMessage ( el . getAttribute ( "hovertext" ) , el [ "clickHandler" ] || null ) ,
940+ APPEAR_TIMEOUT = 500 , tm = 0 ;
959941 el . addEventListener ( "mouseover" , function ( e ) {
960- hm . attach ( e . pageX || e . clientX , e . pageY || e . clientY ) ;
942+ if ( tm ) clearTimeout ( tm ) ;
943+ tm = setTimeout ( function ( ) {
944+ clearTimeout ( tm ) ;
945+ hm . attach ( e . pageX || e . clientX , e . pageY || e . clientY ) ;
946+ } , APPEAR_TIMEOUT ) ;
947+ } ) ;
948+ el . addEventListener ( "mouseout" , function ( ) {
949+ clearTimeout ( tm ) ;
961950 } ) ;
962- //el.addEventListener("mouseout", function () {
963- // hm.detach();
964- //});
965951 } ) ;
966952
967953} ;
0 commit comments