1- {View } = require ' atom'
1+ {View , EditorView } = require ' atom'
2+ {Subscriber } = require ' emissary'
3+
24{Stacktrace , PREFIX } = require ' ./stacktrace'
35
46class StacktraceView extends View
57
8+ Subscriber .includeInto this
9+
610 @ content: (trace ) ->
7- @ div class : ' stacktrace tool-panel padded' , =>
8- @ div class : ' header panel' , =>
9- @ h2 trace .message
11+ tclass = if trace .isActive () then ' activated' else ' '
12+ @ div class : " stacktrace tool-panel padded #{ tclass} " , =>
13+ @ div class : ' panel padded' , =>
14+ @ h2 class : ' error-message' , trace .message
15+ @ p class : ' activate-control' , =>
16+ @ button class : ' btn btn-primary selected inline-block' , click : ' activate' , ' Activate'
17+ @ span class : ' inline-block' , ' to navigate around this stacktrace.'
18+ @ p class : ' deactivate-control' , =>
19+ @ button class : ' btn btn-primary inline-block' , click : ' deactivate' , ' Deactivate'
20+ @ span class : ' inline-block' , ' to close the stacktrace navigation panel.'
1021 @ div class : ' frames' , =>
1122 for frame in trace .frames
12- @ subview ' frame' , new FrameView ( frame)
23+ @ subview ' frame' , new FrameView frame, => trace . activate ( )
1324
1425 initialize : (@trace ) ->
26+ @ subscribe Stacktrace, ' active-changed' , (e ) =>
27+ if e .newTrace is @trace
28+ @ addClass ' activated'
29+ else
30+ @ removeClass ' activated'
31+
32+ beforeRemove : ->
33+ @ unsubscribe Stacktrace
1534
1635 # Internal: Return the window title.
36+ #
1737 getTitle : ->
1838 @trace .message
1939
40+ # Public: Activate the current {Stacktrace}.
41+ #
42+ activate : -> @trace .activate ()
43+
44+ # Public: Deactivate the current {Stacktrace}.
45+ #
46+ deactivate : -> @trace .deactivate ()
47+
2048 # Internal: Register an opener function in the workspace to handle URLs
2149 # generated by a Stacktrace.
50+ #
2251 @ registerIn: (workspace ) ->
2352 workspace .registerOpener (filePath) ->
2453 trace = Stacktrace .forUrl (filePath)
@@ -27,16 +56,35 @@ class StacktraceView extends View
2756
2857class FrameView extends View
2958
30- @ content: (frame ) ->
59+ @ content: (frame , navCallback ) ->
3160 @ div class : ' frame inset-panel' , =>
3261 @ div class : ' panel-heading' , =>
62+ @ span class : ' icon icon-fold inline-block' , click : ' minimize'
63+ @ span class : ' icon icon-unfold inline-block' , click : ' restore'
3364 @ span class : ' function-name text-highlight inline-block' , frame .functionName
34- @ span class : ' source-location text-info inline-block pull-right' , =>
35- @ text " #{ frame .path } @ #{ frame .lineNumber } "
36- @ div class : ' panel-body padded' , =>
37- @ pre output : ' source' , ' Source goes here'
65+ @ span class : ' source-location text-info inline-block pull-right' , click : ' navigate' , =>
66+ @ text " #{ frame .rawPath } @ #{ frame .lineNumber } "
67+ @ div class : ' panel-body padded' , outlet : ' body' , click : ' navigate' , =>
68+ @ subview ' source' , new EditorView (mini : true )
69+
70+ initialize : (@frame , @navCallback ) ->
71+ @frame .getContext 3 , (err , lines ) =>
72+ if err?
73+ console .error err
74+ else
75+ @source .getEditor ().setText lines .join (" \n " )
76+
77+ navigate : ->
78+ @ navCallback ()
79+ @frame .navigateTo ()
80+
81+ minimize : ->
82+ @ addClass ' minimized'
83+ @body .hide ' fast'
3884
39- initialize : (@frame ) ->
85+ restore : ->
86+ @ removeClass ' minimized'
87+ @body .show ' fast'
4088
4189module .exports =
4290 StacktraceView : StacktraceView
0 commit comments