@@ -53,18 +53,16 @@ export default class EventDrops extends Morph {
5353 case 'changed value' :
5454 {
5555 const location = data . value . trigger ;
56- const start = { line : location . line - 1 , ch : location . column } ;
57- lively . openBrowser ( location . source , true , start , false , undefined , true ) ;
56+ this . openLocationInBrowser ( location ) ;
57+
5858 break ;
5959 }
6060 case 'created' :
6161 case 'disposed' :
6262 {
6363 const ae = data . value ;
6464 const location = ae . meta ( ) . get ( "location" ) ;
65- const start = { line : location . start . line - 1 , ch : location . start . column } ;
66- const end = { line : location . end . line - 1 , ch : location . end . column } ;
67- lively . openBrowser ( location . file , true , { start, end } , false , undefined , true ) ;
65+ this . openLocationInBrowser ( location ) ;
6866 break ;
6967 }
7068 case 'dependencies changed' :
@@ -122,7 +120,7 @@ export default class EventDrops extends Morph {
122120 jQuery ( this . aeOverview ) . on ( "changed.jstree" , ( e , data ) => {
123121 this . eventsChanged ( ) ;
124122 } ) ;
125- this . ready = false ;
123+ this . ready = false ;
126124 jQuery ( this . aeOverview ) . one ( "ready.jstree" , ( e , data ) => {
127125 this . ready = true ;
128126 } ) ;
@@ -150,10 +148,22 @@ export default class EventDrops extends Morph {
150148 } ) ;
151149 }
152150
151+ openLocationInBrowser ( location ) {
152+ const start = { line : location . start . line - 1 , ch : location . start . column } ;
153+ const end = { line : location . end . line - 1 , ch : location . end . column } ;
154+ lively . files . exists ( location . file ) . then ( exists => {
155+ if ( exists ) {
156+ lively . openBrowser ( location . file , true , { start, end } , false , undefined , true ) ;
157+ } else {
158+ lively . notify ( "Unable to find file:" + location . file ) ;
159+ }
160+ } ) ;
161+ }
162+
153163 humanizeEventData ( event ) {
154164 switch ( event . type ) {
155165 case 'changed value' :
156- return < div > { this . humanizePosition ( event . value . trigger . source , event . value . trigger . line ) } < br /> < span style = "color:#00AAAA" > { event . value . lastValue } </ span > → < span style = "color:#00AAAA" > { event . value . value } </ span > </ div > ;
166+ return < div > { this . humanizePosition ( event . value . trigger . file , event . value . trigger . start . line ) } < br /> < span style = "color:#00AAAA" > { event . value . lastValue } </ span > → < span style = "color:#00AAAA" > { event . value . value } </ span > </ div > ;
157167 case 'created' :
158168 case 'disposed' :
159169 {
@@ -337,23 +347,17 @@ export default class EventDrops extends Morph {
337347 filterToAEs ( aes ) {
338348 const tree = jQuery ( this . aeOverview ) . jstree ( true ) ;
339349 tree . deselect_all ( ) ;
340- if ( this . ready ) {
341- for ( const ae of aes ) {
350+ if ( this . ready ) {
351+ for ( const ae of aes ) {
342352 tree . select_node ( ae . timelineID + 1 ) ;
343353 }
344- } else {
345- this . filteredAEs = aes ;
346- jQuery ( this . aeOverview ) . on ( "refresh.jstree" , ( e , data ) => {
347- if ( this . filteredAEs ) {
348- for ( const ae of this . filteredAEs ) {
349- tree . select_node ( ae . timelineID + 1 ) ;
350- }
351- if ( tree . get_node ( [ ...this . filteredAEs ] [ 0 ] ) ) {
352- this . filteredAEs = [ ] ;
353- }
354+ } else {
355+ //This is not the best workaround, but the event callbacks do not work reliably
356+ setTimeout ( ( ) => {
357+ for ( const ae of aes ) {
358+ tree . select_node ( ae . timelineID + 1 ) ;
354359 }
355- } ) ;
356- tree . refresh ( ) ;
360+ } , 100 ) ;
357361 }
358362 }
359363
0 commit comments