maglev-webtools 0.2.1 → 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. data/README.rdoc +38 -29
  2. data/bin/webtools +22 -1
  3. data/lib/web_tools/code_browser.rb +156 -0
  4. data/lib/web_tools/debugger.rb +96 -199
  5. data/lib/web_tools/info.rb +1 -3
  6. data/lib/web_tools/method_list.rb +67 -0
  7. data/lib/web_tools/middleware/debugger.rb +10 -16
  8. data/lib/web_tools/object_log.rb +24 -0
  9. data/lib/web_tools/session_list.rb +119 -0
  10. data/lib/web_tools/shared_page_cache.rb +30 -0
  11. data/lib/web_tools/stat_process.rb +24 -0
  12. data/lib/web_tools/statistics.rb +14 -0
  13. data/lib/web_tools/support/app_model.rb +66 -101
  14. data/lib/web_tools/support/code_browser.rb +88 -86
  15. data/lib/web_tools/support/debugger.rb +303 -0
  16. data/lib/web_tools/support/error_log.rb +33 -0
  17. data/lib/web_tools/support/ruby.rb +60 -121
  18. data/lib/web_tools/support/service_helper.rb +38 -10
  19. data/lib/web_tools/support/smalltalk_extensions.rb +12 -0
  20. data/lib/web_tools/tool.rb +48 -0
  21. data/lib/web_tools/ui.rb +14 -53
  22. data/lib/web_tools/version_report.rb +29 -0
  23. data/lib/web_tools/workspace.rb +77 -0
  24. data/lib/web_tools.rb +14 -4
  25. data/public/CodeBrowser.html +51 -0
  26. data/public/CodeMirror/LICENSE +19 -0
  27. data/public/CodeMirror/css/codemirror.css +67 -0
  28. data/public/CodeMirror/css/default.css +18 -0
  29. data/public/CodeMirror/js/codemirror.js +2131 -0
  30. data/public/CodeMirror/js/ruby.js +195 -0
  31. data/public/CodeMirror/js/smalltalk.js +139 -0
  32. data/public/Debugger.html +28 -0
  33. data/public/MethodList.html +20 -0
  34. data/public/ObjectLog.html +20 -0
  35. data/public/SessionList.html +31 -0
  36. data/public/SharedPageCache.html +78 -0
  37. data/public/Statistics.html +64 -0
  38. data/public/VersionReport.html +50 -0
  39. data/public/Workspace.html +39 -0
  40. data/public/css/CodeBrowser.css +24 -0
  41. data/public/css/Debugger.css +32 -0
  42. data/public/css/MethodList.css +8 -0
  43. data/public/css/ObjectLog.css +5 -0
  44. data/public/css/SessionList.css +9 -0
  45. data/public/css/Statistics.css +24 -0
  46. data/public/{stylesheets → css}/base/images/ui-anim_basic_16x16.gif +0 -0
  47. data/public/{stylesheets → css}/base/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  48. data/public/{stylesheets → css}/base/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  49. data/public/{stylesheets → css}/base/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  50. data/public/{stylesheets → css}/base/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  51. data/public/{stylesheets → css}/base/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  52. data/public/{stylesheets → css}/base/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  53. data/public/{stylesheets → css}/base/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  54. data/public/{stylesheets → css}/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  55. data/public/{stylesheets → css}/base/images/ui-icons_222222_256x240.png +0 -0
  56. data/public/{stylesheets → css}/base/images/ui-icons_2e83ff_256x240.png +0 -0
  57. data/public/{stylesheets → css}/base/images/ui-icons_454545_256x240.png +0 -0
  58. data/public/{stylesheets → css}/base/images/ui-icons_888888_256x240.png +0 -0
  59. data/public/{stylesheets → css}/base/images/ui-icons_cd0a0a_256x240.png +0 -0
  60. data/public/{stylesheets → css}/base/jquery.ui.accordion.css +0 -0
  61. data/public/{stylesheets → css}/base/jquery.ui.all.css +0 -0
  62. data/public/{stylesheets → css}/base/jquery.ui.autocomplete.css +0 -0
  63. data/public/{stylesheets → css}/base/jquery.ui.base.css +0 -0
  64. data/public/{stylesheets → css}/base/jquery.ui.button.css +0 -0
  65. data/public/{stylesheets → css}/base/jquery.ui.core.css +0 -0
  66. data/public/{stylesheets → css}/base/jquery.ui.datepicker.css +0 -0
  67. data/public/{stylesheets → css}/base/jquery.ui.dialog.css +0 -0
  68. data/public/{stylesheets → css}/base/jquery.ui.progressbar.css +0 -0
  69. data/public/{stylesheets → css}/base/jquery.ui.resizable.css +0 -0
  70. data/public/{stylesheets → css}/base/jquery.ui.selectable.css +0 -0
  71. data/public/{stylesheets → css}/base/jquery.ui.slider.css +0 -0
  72. data/public/{stylesheets → css}/base/jquery.ui.tabs.css +0 -0
  73. data/public/{stylesheets → css}/base/jquery.ui.theme.css +0 -0
  74. data/public/css/editor.css +25 -0
  75. data/public/css/jjmenu.css +33 -0
  76. data/public/css/menuitem.gif +0 -0
  77. data/public/css/more.gif +0 -0
  78. data/public/{stylesheets → css}/reset.css +1 -1
  79. data/public/css/smoothness/images/ui-anim_basic_16x16.gif +0 -0
  80. data/public/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  81. data/public/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  82. data/public/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  83. data/public/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  84. data/public/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  85. data/public/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  86. data/public/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  87. data/public/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  88. data/public/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
  89. data/public/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  90. data/public/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
  91. data/public/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
  92. data/public/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  93. data/public/css/smoothness/jquery-ui.css +489 -0
  94. data/public/css/ui-lightness/images/ui-anim_basic_16x16.gif +0 -0
  95. data/public/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  96. data/public/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  97. data/public/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  98. data/public/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  99. data/public/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  100. data/public/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  101. data/public/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  102. data/public/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  103. data/public/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  104. data/public/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  105. data/public/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  106. data/public/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  107. data/public/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  108. data/public/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  109. data/public/css/ui-lightness/jquery-ui.css +489 -0
  110. data/public/css/webtools.css +65 -0
  111. data/public/favicon.ico +0 -0
  112. data/public/flot/API.txt +1201 -0
  113. data/public/flot/FAQ.txt +76 -0
  114. data/public/flot/LICENSE.txt +22 -0
  115. data/public/flot/Makefile +9 -0
  116. data/public/flot/NEWS.txt +508 -0
  117. data/public/flot/PLUGINS.txt +137 -0
  118. data/public/flot/README.txt +90 -0
  119. data/public/flot/examples/ajax.html +143 -0
  120. data/public/flot/examples/annotating.html +75 -0
  121. data/public/flot/examples/arrow-down.gif +0 -0
  122. data/public/flot/examples/arrow-left.gif +0 -0
  123. data/public/flot/examples/arrow-right.gif +0 -0
  124. data/public/flot/examples/arrow-up.gif +0 -0
  125. data/public/flot/examples/basic.html +38 -0
  126. data/public/flot/examples/data-eu-gdp-growth-1.json +4 -0
  127. data/public/flot/examples/data-eu-gdp-growth-2.json +4 -0
  128. data/public/flot/examples/data-eu-gdp-growth-3.json +4 -0
  129. data/public/flot/examples/data-eu-gdp-growth-4.json +4 -0
  130. data/public/flot/examples/data-eu-gdp-growth-5.json +4 -0
  131. data/public/flot/examples/data-eu-gdp-growth.json +4 -0
  132. data/public/flot/examples/data-japan-gdp-growth.json +4 -0
  133. data/public/flot/examples/data-usa-gdp-growth.json +4 -0
  134. data/public/flot/examples/graph-types.html +75 -0
  135. data/public/flot/examples/hs-2004-27-a-large_web.jpg +0 -0
  136. data/public/flot/examples/image.html +45 -0
  137. data/public/flot/examples/index.html +44 -0
  138. data/public/flot/examples/interacting-axes.html +97 -0
  139. data/public/flot/examples/interacting.html +93 -0
  140. data/public/flot/examples/layout.css +6 -0
  141. data/public/flot/examples/multiple-axes.html +60 -0
  142. data/public/flot/examples/navigate.html +118 -0
  143. data/public/flot/examples/percentiles.html +57 -0
  144. data/public/flot/examples/pie.html +756 -0
  145. data/public/flot/examples/realtime.html +83 -0
  146. data/public/flot/examples/resize.html +61 -0
  147. data/public/flot/examples/selection.html +114 -0
  148. data/public/flot/examples/setting-options.html +61 -0
  149. data/public/flot/examples/stacking.html +77 -0
  150. data/public/flot/examples/symbols.html +49 -0
  151. data/public/flot/examples/thresholding.html +54 -0
  152. data/public/flot/examples/time.html +71 -0
  153. data/public/flot/examples/tracking.html +95 -0
  154. data/public/flot/examples/turning-series.html +98 -0
  155. data/public/flot/examples/visitors.html +90 -0
  156. data/public/flot/examples/zooming.html +98 -0
  157. data/public/flot/excanvas.js +1427 -0
  158. data/public/flot/excanvas.min.js +1 -0
  159. data/public/flot/jquery.colorhelpers.js +179 -0
  160. data/public/flot/jquery.colorhelpers.min.js +1 -0
  161. data/public/flot/jquery.flot.crosshair.js +167 -0
  162. data/public/flot/jquery.flot.crosshair.min.js +1 -0
  163. data/public/flot/jquery.flot.fillbetween.js +183 -0
  164. data/public/flot/jquery.flot.fillbetween.min.js +1 -0
  165. data/public/flot/jquery.flot.image.js +238 -0
  166. data/public/flot/jquery.flot.image.min.js +1 -0
  167. data/public/flot/jquery.flot.js +2599 -0
  168. data/public/flot/jquery.flot.min.js +6 -0
  169. data/public/flot/jquery.flot.navigate.js +336 -0
  170. data/public/flot/jquery.flot.navigate.min.js +1 -0
  171. data/public/flot/jquery.flot.pie.js +750 -0
  172. data/public/flot/jquery.flot.pie.min.js +1 -0
  173. data/public/flot/jquery.flot.resize.js +60 -0
  174. data/public/flot/jquery.flot.resize.min.js +1 -0
  175. data/public/flot/jquery.flot.selection.js +344 -0
  176. data/public/flot/jquery.flot.selection.min.js +1 -0
  177. data/public/flot/jquery.flot.stack.js +184 -0
  178. data/public/flot/jquery.flot.stack.min.js +1 -0
  179. data/public/flot/jquery.flot.symbol.js +70 -0
  180. data/public/flot/jquery.flot.symbol.min.js +1 -0
  181. data/public/flot/jquery.flot.threshold.js +103 -0
  182. data/public/flot/jquery.flot.threshold.min.js +1 -0
  183. data/public/flot/jquery.js +8316 -0
  184. data/public/flot/jquery.min.js +23 -0
  185. data/public/genPacking.pl +30 -0
  186. data/public/index.html +28 -0
  187. data/public/install.tpz +66 -0
  188. data/public/installAndRun.tpz +5 -0
  189. data/public/jsTree/jquery.jstree.js +3510 -0
  190. data/public/jsTree/themes/default/d.gif +0 -0
  191. data/public/jsTree/themes/default/d.png +0 -0
  192. data/public/jsTree/themes/default/style.css +73 -0
  193. data/public/jsTree/themes/default/throbber.gif +0 -0
  194. data/public/readMe.txt +9 -0
  195. data/public/scripts/CodeBrowser.js +645 -0
  196. data/public/scripts/Debugger.js +134 -0
  197. data/public/scripts/MethodList.js +72 -0
  198. data/public/scripts/ObjectLog.js +59 -0
  199. data/public/scripts/SessionList.js +164 -0
  200. data/public/scripts/Statistics.js +266 -0
  201. data/public/scripts/editor.js +430 -0
  202. data/public/scripts/jjmenu.js +375 -0
  203. data/public/scripts/jquery-ui.js +1012 -0
  204. data/public/scripts/jquery.js +154 -0
  205. data/public/scripts/webtools.js +374 -0
  206. data/public/src/CodeBrowser.gs +416 -0
  207. data/public/src/Debugger.gs +132 -0
  208. data/public/src/MethodList.gs +130 -0
  209. data/public/src/ObjectLog.gs +73 -0
  210. data/public/src/Server.gs +544 -0
  211. data/public/src/SessionList.gs +172 -0
  212. data/public/src/SharedPageCache.gs +66 -0
  213. data/public/src/StatProcess.gs +280 -0
  214. data/public/src/StatProcessType.gs +242 -0
  215. data/public/src/StatStatistic.gs +381 -0
  216. data/public/src/Statistics.gs +222 -0
  217. data/public/src/Statmonitor.gs +490 -0
  218. data/public/src/Tool.gs +86 -0
  219. data/public/src/VersionReport.gs +52 -0
  220. data/public/src/Workspace.gs +163 -0
  221. data/views/debugger.rhtml +6 -9
  222. metadata +344 -243
  223. data/lib/web_tools/#debugger.rb# +0 -212
  224. data/lib/web_tools/browser.rb +0 -45
  225. data/public/images/favicon.ico +0 -0
  226. data/public/javascript/CodeMirror/LICENSE +0 -23
  227. data/public/javascript/CodeMirror/css/Smalltalk.css +0 -34
  228. data/public/javascript/CodeMirror/js/codemirror.js +0 -582
  229. data/public/javascript/CodeMirror/js/editor.js +0 -1671
  230. data/public/javascript/CodeMirror/js/highlight.js +0 -68
  231. data/public/javascript/CodeMirror/js/parseSmalltalk.js +0 -126
  232. data/public/javascript/CodeMirror/js/parsedummy.js +0 -32
  233. data/public/javascript/CodeMirror/js/select.js +0 -699
  234. data/public/javascript/CodeMirror/js/stringstream.js +0 -159
  235. data/public/javascript/CodeMirror/js/tokenize.js +0 -57
  236. data/public/javascript/CodeMirror/js/undo.js +0 -413
  237. data/public/javascript/CodeMirror/js/util.js +0 -133
  238. data/public/javascript/CodeMirror/testSmalltalkParser.html +0 -116
  239. data/public/javascript/ace/ace-uncompressed.js +0 -17299
  240. data/public/javascript/ace/ace.js +0 -1
  241. data/public/javascript/ace/keybinding-emacs.js +0 -1
  242. data/public/javascript/ace/keybinding-vim.js +0 -1
  243. data/public/javascript/ace/mode-c_cpp.js +0 -1
  244. data/public/javascript/ace/mode-clojure.js +0 -1
  245. data/public/javascript/ace/mode-coffee.js +0 -1
  246. data/public/javascript/ace/mode-csharp.js +0 -1
  247. data/public/javascript/ace/mode-css.js +0 -1
  248. data/public/javascript/ace/mode-groovy.js +0 -1
  249. data/public/javascript/ace/mode-html.js +0 -1
  250. data/public/javascript/ace/mode-java.js +0 -1
  251. data/public/javascript/ace/mode-javascript.js +0 -1
  252. data/public/javascript/ace/mode-json.js +0 -1
  253. data/public/javascript/ace/mode-lua.js +0 -1
  254. data/public/javascript/ace/mode-markdown.js +0 -1
  255. data/public/javascript/ace/mode-ocaml.js +0 -1
  256. data/public/javascript/ace/mode-perl.js +0 -1
  257. data/public/javascript/ace/mode-php.js +0 -1
  258. data/public/javascript/ace/mode-python.js +0 -1
  259. data/public/javascript/ace/mode-ruby.js +0 -1
  260. data/public/javascript/ace/mode-scad.js +0 -1
  261. data/public/javascript/ace/mode-scala.js +0 -1
  262. data/public/javascript/ace/mode-scss.js +0 -1
  263. data/public/javascript/ace/mode-svg.js +0 -1
  264. data/public/javascript/ace/mode-textile.js +0 -1
  265. data/public/javascript/ace/mode-xml.js +0 -1
  266. data/public/javascript/ace/theme-clouds.js +0 -1
  267. data/public/javascript/ace/theme-clouds_midnight.js +0 -1
  268. data/public/javascript/ace/theme-cobalt.js +0 -1
  269. data/public/javascript/ace/theme-crimson_editor.js +0 -1
  270. data/public/javascript/ace/theme-dawn.js +0 -1
  271. data/public/javascript/ace/theme-eclipse.js +0 -1
  272. data/public/javascript/ace/theme-idle_fingers.js +0 -1
  273. data/public/javascript/ace/theme-kr_theme.js +0 -1
  274. data/public/javascript/ace/theme-merbivore.js +0 -1
  275. data/public/javascript/ace/theme-merbivore_soft.js +0 -1
  276. data/public/javascript/ace/theme-mono_industrial.js +0 -1
  277. data/public/javascript/ace/theme-monokai.js +0 -1
  278. data/public/javascript/ace/theme-pastel_on_dark.js +0 -1
  279. data/public/javascript/ace/theme-solarized_dark.js +0 -1
  280. data/public/javascript/ace/theme-solarized_light.js +0 -1
  281. data/public/javascript/ace/theme-textmate.js +0 -1
  282. data/public/javascript/ace/theme-twilight.js +0 -1
  283. data/public/javascript/ace/theme-vibrant_ink.js +0 -1
  284. data/public/javascript/ace/worker-coffee.js +0 -1
  285. data/public/javascript/ace/worker-css.js +0 -1
  286. data/public/javascript/ace/worker-javascript.js +0 -1
  287. data/public/javascript/webtools/browser.js +0 -260
  288. data/public/javascript/webtools/debugger.coffee +0 -286
  289. data/public/javascript/webtools/debugger.js +0 -366
  290. data/public/javascript/webtools/sessions.coffee +0 -17
  291. data/public/javascript/webtools/sessions.js +0 -27
  292. data/public/javascript/webtools/version.coffee +0 -14
  293. data/public/javascript/webtools/version.js +0 -20
  294. data/public/stylesheets/jquery.contextMenu.css +0 -62
  295. data/public/stylesheets/webtools.css +0 -53
  296. data/public/test.html +0 -47
@@ -0,0 +1,430 @@
1
+ GemStone.saveScript('scripts/editor.js', function(options) {
2
+ var editor
3
+ , isMethod = false
4
+ , dictionaryName
5
+ , className
6
+ , isMeta = false
7
+ , category
8
+ , source = ''
9
+ , errorInfo = {}
10
+ , stepPoints
11
+ , unmarkFunctions = []
12
+ , mousePosition = { x: 0, y: 0 }
13
+ , onSaveFunction
14
+ ;
15
+ GemStone.loadCSS('CodeMirror/css/codemirror.css');
16
+ GemStone.loadCSS('CodeMirror/css/default.css');
17
+ GemStone.loadCSS('css/editor.css');
18
+ GemStone.runJsOnce('CodeMirror/js/codemirror.js', function() {
19
+ GemStone.runJsOnce('CodeMirror/js/ruby.js', function() {});
20
+ GemStone.runJsOnce('CodeMirror/js/smalltalk.js', function() {
21
+ setupEditor();
22
+ });
23
+ });
24
+ return {
25
+ isOkayToChange: isOkayToChange
26
+ , isModified: isModified
27
+ , setCode: setCode
28
+ , setMethod: setMethod
29
+ };
30
+
31
+ function setupEditor() {
32
+ var id = GemStone.nextId();
33
+ options.editArea.attr('id', id);
34
+ editor = CodeMirror(document.getElementById(id), {
35
+ mode: 'text/x-stsrc'
36
+ , enterMode: 'keep'
37
+ , lineNumbers: true
38
+ , matchBrackets: true
39
+ , onChange: onEditorChange
40
+ , onHighlightComplete: onHighlightComplete
41
+ });
42
+ options.editArea.focus(setFocusToEnd);
43
+ $(editor.getWrapperElement()).mousemove( function(e) {
44
+ mousePosition.x = e.pageX;
45
+ mousePosition.y = e.pageY;
46
+ });
47
+ options.editArea.keydown(keydown);
48
+ $(editor.getWrapperElement()).focus();
49
+ }
50
+
51
+ // keypress does not <Ctrl>+<S> (and other browser overrides) so we use keydown event
52
+ function keydown(event) {
53
+ if (!event.ctrlKey) { return; }
54
+ // console.log(event);
55
+ if (event.keyCode === 65) { // <Ctrl>+<A>
56
+ var lastLine = editor.lineCount() - 1
57
+ , size = editor.getLine(lastLine).length
58
+ , end = { line: lastLine, ch: size }
59
+ , start = { line: 0, ch: 0 }
60
+ ;
61
+ editor.setSelection(start, end);
62
+ event.preventDefault();
63
+ return;
64
+ }
65
+ if (event.keyCode === 68) { // <Ctrl>+<D>
66
+ evaluateText();
67
+ event.preventDefault();
68
+ return;
69
+ }
70
+ if (event.keyCode === 83) { // <Ctrl>+<S>
71
+ saveText();
72
+ event.preventDefault();
73
+ return;
74
+ }
75
+ return;
76
+ }
77
+
78
+ function evaluateText() {
79
+ var pos = editor.getCursor(true)
80
+ , start = { line: pos.line, ch: pos.ch }
81
+ ;
82
+ pos = editor.getCursor(false);
83
+ var end = { line: pos.line, ch: pos.ch }
84
+ , myRequest;
85
+ if (!editor.somethingSelected()) {
86
+ start.ch = 0;
87
+ end.ch = editor.getLine(start.line).length;
88
+ editor.setSelection(start, end);
89
+ }
90
+ myRequest = { text: editor.getRange(start, end) };
91
+ GemStone.ajax('POST','Workspace/evaluate', myRequest, onEvaluate);
92
+ return;
93
+
94
+ function onEvaluate(data) {
95
+ if (!data.errorType) {
96
+ start = editor.getCursor(false);
97
+ editor.setCursor(start);
98
+ editor.replaceRange(' ' + data.string, start);
99
+ var end = editor.getCursor(false);
100
+ editor.setSelection(start, end);
101
+ return;
102
+ }
103
+ if (data.errorType === 'compileError') {
104
+ compileError(data.errorDetails);
105
+ return;
106
+ }
107
+ if (confirm(data.description + '\nDebug process?')) {
108
+ GemStone.ajax(
109
+ 'GET'
110
+ , 'Debugger.html'
111
+ , null
112
+ , function(html) {
113
+ var string = html.replace('OOP', data.oop);
114
+ $('body').append(string);
115
+ }
116
+ );
117
+ return;
118
+ } else {
119
+ GemStone.ajax('POST', 'Workspace/deleteProcess', data);
120
+ }
121
+ console.log(data);
122
+ }
123
+ }
124
+
125
+ function saveText() {
126
+ if (isMethod) {
127
+ saveMethod();
128
+ } else {
129
+ saveCode();
130
+ }
131
+ }
132
+
133
+ function saveCode() {
134
+ var myRequest = {
135
+ text: editor.getValue()
136
+ };
137
+ GemStone.ajax('POST','Workspace/evaluate', myRequest, onSaveCode);
138
+ return;
139
+
140
+ function onSaveCode(data) {
141
+ if (!data.errorType) {
142
+ source = editor.getValue();
143
+ if (onSaveFunction) { onSaveFunction(data); }
144
+ return;
145
+ }
146
+ if (data.errorType === 'compileError') {
147
+ compileError(data.errorDetails);
148
+ return;
149
+ }
150
+ }
151
+ }
152
+
153
+ function compileError(data) {
154
+ var position = positionOfOffset(data[0][1]);
155
+ editor.replaceRange('\n', { line: position.line + 1, ch: 0 });
156
+ errorInfo.position = position;
157
+ errorInfo.element = document.createElement('div');
158
+ $(errorInfo.element).addClass('compileError');
159
+ $(errorInfo.element).text('^-' + data[0][2]);
160
+ editor.addWidget(position, errorInfo.element, true);
161
+ }
162
+
163
+ function saveMethod() {
164
+ var myRequest = {
165
+ dict: dictionaryName
166
+ , klass: className
167
+ , isMeta: isMeta
168
+ , category: category
169
+ , selector: editor.selector
170
+ , source: editor.getValue()
171
+ };
172
+ GemStone.ajax('POST','Workspace/saveMethod', myRequest, onSaveMethod);
173
+ return;
174
+
175
+ function onSaveMethod(data) {
176
+ if (data.compileError) { compileError(data.compileError); return; }
177
+ source = editor.getValue();
178
+ if (data.warnings) { alert(data.warnings); }
179
+ if (onSaveFunction) { onSaveFunction(data.selector); }
180
+ }
181
+ }
182
+
183
+
184
+
185
+ function setFocusToEnd() {
186
+ var line = editor.lineCount()
187
+ , string = editor.getLine(line - 1)
188
+ , ch = string.length - 1
189
+ ;
190
+ editor.focus();
191
+ editor.setCursor(line, ch);
192
+ }
193
+
194
+ function onEditorChange() {
195
+ stepPoints = new Array; // [zero-based offset, one-based step-point, selector]
196
+ doUnmark();
197
+ if (errorInfo.position) {
198
+ var line = errorInfo.position.line + 1;
199
+ errorInfo.position = null;
200
+ $(errorInfo.element).remove();
201
+ editor.removeLine(line);
202
+ }
203
+ }
204
+
205
+ function doUnmark() {
206
+ $.each(unmarkFunctions, function(i, aFunction) { aFunction(); });
207
+ unmarkFunctions = [];
208
+ }
209
+
210
+ function isOkayToChange() {
211
+ if (!isModified()) { return true; }
212
+ if (confirm('Okay to lose edits?')) {
213
+ source = editor.getValue();
214
+ return true;
215
+ }
216
+ return false;
217
+ }
218
+
219
+ function isModified() {
220
+ return (editor ? editor.getValue() !== source : false);
221
+ };
222
+
223
+ function setMethod(data, aFunction) {
224
+ if (!editor) { return; }
225
+ isMethod = true;
226
+ onSaveFunction = aFunction;
227
+ doUnmark();
228
+ editor.setValue('');
229
+ stepPoints = new Array(); // [zero-based offset, one-based step-point, selector]
230
+ if (!data) { return; }
231
+ dictionaryName = data.dictionaryName;
232
+ className = data.className;
233
+ isMeta = data.isMeta;
234
+ category = data.category;
235
+ editor.selector = data.selector;
236
+ source = data.source ? data.source : '';
237
+ setCodeMode(source);
238
+ editor.setValue(source);
239
+ calculateStepPoints(data);
240
+ }
241
+
242
+ function setCode(aString, aFunction) {
243
+ if (!editor) { return; }
244
+ isMethod = false;
245
+ onSaveFunction = aFunction;
246
+ doUnmark();
247
+ editor.setValue('');
248
+ stepPoints = [];
249
+ if (!aString) { return; }
250
+ dictionaryName = null;
251
+ className = null;
252
+ isMeta = null;
253
+ category = null;
254
+ source = aString;
255
+ setCodeMode(source);
256
+ editor.setValue(source);
257
+ }
258
+
259
+ function setCodeMode(source) {
260
+ ruby_regex = /^\s*(def|do|begin|<a define)/
261
+ smalltalk_regex = /^[_a-zA-Z0-9]+:/
262
+ if (source.match(ruby_regex)) {
263
+ editor.setOption('mode', 'text/x-ruby');
264
+ } else if (source.match(smalltalk_regex)) {
265
+ editor.setOption('mode', 'text/x-stsrc');
266
+ } else {
267
+ editor.setOption('mode', 'text/x-stsrc');
268
+ }
269
+ }
270
+
271
+ function calculateStepPoints(data) {
272
+ if (!data.stepPoints) { return; }
273
+ for (var i = 0; i < data.stepPoints.length; i = i + 1) {
274
+ var offset = data.stepPoints[i] - 1
275
+ , from = positionOfOffset(offset + 2)
276
+ , token = editor.getTokenAt(from)
277
+ , to = { line: from.line, ch: token.end }
278
+ , lineInfo
279
+ , cssClass
280
+ ;
281
+ cssClass = 'gsStepPoint';
282
+ if (i + 1 === data.nowAt) { cssClass = cssClass + ' gsCurrentStepPoint'; }
283
+ from.ch = from.ch - 1;
284
+ unmarkFunctions[unmarkFunctions.length] = editor.markText(from, to, cssClass);
285
+ stepPoints[stepPoints.length] = [offset, i + 1];
286
+ }
287
+ for (var i = 0; i < data.sends.length; i = i + 2) {
288
+ var offset = data.sends[i] - 1
289
+ , selector = data.sends[i + 1]
290
+ , stepPoint = stepPointDataFor(offset)
291
+ ;
292
+ stepPoint[2] = selector;
293
+ }
294
+ GemStone.menu({
295
+ selector: $(editor.getWrapperElement())
296
+ , menu: editorMenu
297
+ });
298
+ }
299
+
300
+ function positionOfOffset(anInteger) {
301
+ var lines = editor.getValue().split('\n')
302
+ , start = 0
303
+ , end = 0
304
+ , position = {
305
+ line: lines.length - 1,
306
+ ch: lines[lines.length - 1].length - 1
307
+ }
308
+ ;
309
+ $.each(lines, function(i, line) {
310
+ start = end;
311
+ end = start + line.length + 1;
312
+ if (start <= anInteger && anInteger <= end) {
313
+ position = { line: i, ch: anInteger - start - 1 };
314
+ }
315
+ });
316
+ return position;
317
+ }
318
+
319
+ function offsetOfPosition(position) {
320
+ var offset = null
321
+ , lines = editor.getValue().split('\n')
322
+ , start = 0
323
+ , end = 0
324
+ ;
325
+ $.each(lines, function(i, line) {
326
+ start = end;
327
+ end = start + line.length + 1;
328
+ if (i === position.line) {
329
+ offset = start + position.ch;
330
+ }
331
+ });
332
+ return offset;
333
+ }
334
+
335
+ function stepPointDataFor(offset) {
336
+ var value;
337
+ $.each(stepPoints, function(i, stepPoint) {
338
+ // if mouse is to left of step point, allow it
339
+ if (stepPoint[0] === offset + 1) { value = stepPoint; }
340
+ if (stepPoint[0] === offset) { value = stepPoint; }
341
+ });
342
+ return value;
343
+ }
344
+
345
+ function editorMenu(element) {
346
+ var coordsChar = editor.coordsChar(mousePosition)
347
+ , token = editor.getTokenAt(coordsChar)
348
+ , offset = offsetOfPosition({line: coordsChar.line, ch: token.start})
349
+ , stepPointData = stepPointDataFor(offset)
350
+ , stepPoint = stepPointData ? stepPointData[1] : null
351
+ , mySelector = stepPointData ? stepPointData[2] : null
352
+ , items = []
353
+ ;
354
+ if (stepPoint) {
355
+ items[0] = {
356
+ title: 'Step Point ' + stepPoint
357
+ , customClass: 'disabled'
358
+ , action: function() {}
359
+ };
360
+ if (mySelector) {
361
+ items[1] = {
362
+ title: 'Implementors of ' + mySelector
363
+ , action: function() { GemStone.browseImplementorsOf(mySelector); }
364
+ };
365
+ items[2] = {
366
+ title: 'Senders of ' + mySelector
367
+ , action: function() { GemStone.browseSendersOf(mySelector); }
368
+ };
369
+ }
370
+ }
371
+ items[items.length] = {
372
+ title: 'Implementors of ...'
373
+ , action: function() { GemStone.browseImplementorsOf(); }
374
+ };
375
+ items[items.length] = {
376
+ title: 'Senders of ...'
377
+ , action: function() { GemStone.browseSendersOf(); }
378
+ };
379
+ return items;
380
+ }
381
+
382
+ function onHighlightComplete(anEditor) {
383
+ // console.log('onHighlightComplete');
384
+ }
385
+
386
+ /*
387
+ , 'Undo': {
388
+ click: function(element) { console.log('Undo'); }
389
+ }
390
+ , 'Redo': {
391
+ click: function(element) { console.log('Redo'); }
392
+ }
393
+ , '------------': {
394
+ click: function(element) { }
395
+ , klass: 'separator'
396
+ }
397
+ , 'Cut': {
398
+ click: function(element) { console.log('Cut'); }
399
+ }
400
+ , 'Copy': {
401
+ click: function(element) { console.log('Copy'); }
402
+ }
403
+ , 'Paste': {
404
+ click: function(element) { console.log('Paste'); }
405
+ }
406
+ , 'Delete': {
407
+ click: function(element) { console.log('Delete'); }
408
+ }
409
+ , '-----------': {
410
+ click: function(element) { }
411
+ , klass: 'separator'
412
+ }
413
+ , 'Select All': {
414
+ click: function(element) { console.log('Select All'); }
415
+ }
416
+ , '----------': {
417
+ click: function(element) { }
418
+ , klass: 'separator'
419
+ }
420
+ , 'Senders': {
421
+ click: function(element) { browseSenders(selector); }
422
+ , klass: 'gsSenders'
423
+ }
424
+ , 'Implementors': {
425
+ click: function(element) { browseImplementors(selector); }
426
+ , klass: 'gsImplementors'
427
+ }
428
+ }
429
+ */
430
+ });
@@ -0,0 +1,375 @@
1
+ /* jjmenu - context menu jquery plugin
2
+ * http://jursza.net/dev/jjmenu/
3
+ *
4
+ * @author Jacek Jursza (okhan.pl@gmail.com)
5
+ * @version 1.1.2
6
+ * @date 2010-08-28
7
+ * @category jQuery plugin
8
+ * @copyright (c) 2009 Jacek Jursza (http://jursza.net/)
9
+ * @licence MIT [http://www.opensource.org/licenses/mit-license.php]
10
+ */
11
+
12
+ (function($){
13
+
14
+ $.fn.jjmenu = function (clickEvent, param, myReplaces, effect) {
15
+
16
+ var global = this;
17
+ var acceptEvent = false;
18
+
19
+
20
+ if ( clickEvent == "rightClick" || clickEvent == "both" )
21
+ {
22
+ global.mousedown(function(event) {
23
+ if (event.button == 2 && (clickEvent == "rightClick" || clickEvent == "both")) { // right click
24
+ global.pageX = event.pageX;
25
+ global.pageY = event.pageY;
26
+ event.preventDefault();
27
+ event.stopPropagation();
28
+ var mmain = new menu("main", param, myReplaces, this, effect);
29
+ $(this)[0].oncontextmenu = function() {
30
+ return false;
31
+ }
32
+ $(this).unbind('mouseup');
33
+ $(this).blur();
34
+ return false;
35
+ }
36
+ });
37
+
38
+ document.body.oncontextmenu = function() {
39
+ if ($("div[id^=jjmenu_main]").length) return false;
40
+ }
41
+ }
42
+
43
+ if ( clickEvent == "click" || clickEvent == "both" )
44
+ {
45
+ global.click(
46
+ function(event) {
47
+ if (this == event.target) {
48
+ global.pageX = event.pageX;
49
+ global.pageY = event.pageY;
50
+ event.preventDefault();
51
+ event.stopPropagation();
52
+ var mmain = new menu("main", param, myReplaces, this, effect);
53
+ $(this).blur();
54
+ return false;
55
+ }
56
+ });
57
+ }
58
+
59
+ $(document).click(function(event) { if (event.button!=2) $("div[id^=jjmenu]").remove(); });
60
+
61
+ /* Menu obeject */
62
+ function menu(id,param,myReplaces,el,effect) {
63
+
64
+ var effect = getEffect(id, effect);
65
+
66
+ if (id == "main") window.triggerElement = el;
67
+ $("div[id^=jjmenu_"+id+"]").remove();
68
+
69
+ var m = document.createElement('div');
70
+ var ms = document.createElement('span');
71
+ $(m).append(ms);
72
+
73
+ m.className = "jjmenu"; m.id = "jjmenu_"+id;
74
+ $(m).css({display:'none'});
75
+ $(document.body).append(m);
76
+
77
+ positionMenu();
78
+
79
+ var dynamicItems = false;
80
+
81
+ for (var i in param) {
82
+
83
+ if (param[i].get) {
84
+
85
+ dynamicItems = true;
86
+ $.getJSON(uReplace(param[i].get), function(data) {
87
+ for (var ii in data) {
88
+ putItem(data[ii]);
89
+ }
90
+ checkPosition();
91
+ })
92
+ $(this).ajaxError( function() {
93
+ checkPosition();
94
+ });
95
+ }
96
+ else if (param[i].getByFunction) {
97
+
98
+ if (typeof(param[i].getByFunction) == "function") {
99
+ var uF = param[i].getByFunction;
100
+ }
101
+ else {
102
+ var uF = eval(param[i].getByFunction);
103
+ }
104
+ var uItems = uF(myReplaces);
105
+ for (var ii in uItems) {
106
+ putItem(uItems[ii]);
107
+ }
108
+ checkPosition();
109
+ }
110
+ else {
111
+ putItem(param[i]);
112
+ }
113
+ }
114
+
115
+ if (!dynamicItems) checkPosition();
116
+ showMenu();
117
+
118
+ /* first position menu */
119
+ function positionMenu() {
120
+
121
+ var pos = $(el).offset();
122
+
123
+ var t = pos.top;
124
+
125
+ if (effect.xposition == "left") {
126
+ var l = pos.left;
127
+ }
128
+ else {
129
+ var l = pos.left+$(el).width()+10;
130
+ }
131
+
132
+ if (effect.xposition == "mouse") {
133
+ l = global.pageX;
134
+ }
135
+ if (effect.yposition == "mouse") {
136
+ t = global.pageY;
137
+ }
138
+
139
+ $(m).css({position:"absolute",top:t+"px",left:l+"px"});
140
+ }
141
+
142
+ /* correct menu position */
143
+ function checkPosition() {
144
+
145
+ var isHidden = $(m).css("display") == "none" ? true : false;
146
+ var noAuto = false;
147
+
148
+ if (effect.orientation == "top" || effect.orientation == "bottom") {
149
+ noAuto = true;
150
+ }
151
+
152
+ if (isHidden) $(m).show();
153
+ var positionTop = $(m).offset().top;
154
+ var positionLeft = $(m).offset().left;
155
+ if (isHidden) $(m).hide();
156
+
157
+ var xPos = positionTop - $(window).scrollTop();
158
+
159
+ $(m).css({left:"0px"});
160
+ var menuHeight = $(m).outerHeight();
161
+ var menuWidth = $(m).outerWidth();
162
+ $(m).css({left:positionLeft+"px"});
163
+
164
+ var nleft = positionLeft;
165
+ if ( positionLeft + menuWidth > $(window).width() ) {
166
+ nleft = $(window).width() - menuWidth;
167
+ }
168
+
169
+ var spaceBottom = true;
170
+ if (effect.yposition == "auto" && effect.xposition == "left") {
171
+
172
+ if ( xPos + menuHeight + $(el).outerHeight() > $(window).height()) {
173
+ spaceBottom = false;
174
+ }
175
+ }
176
+ else {
177
+
178
+ if ( xPos + menuHeight > $(window).height()) {
179
+ spaceBottom = false;
180
+ }
181
+ }
182
+
183
+ var spaceTop = true;
184
+ if (positionTop - menuHeight < 0) {
185
+ spaceTop = false;
186
+ }
187
+
188
+ if (effect.yposition == "bottom") {
189
+ positionTop = positionTop + $(el).outerHeight();
190
+ }
191
+
192
+ if ( (effect.orientation == "auto" && spaceBottom == false && spaceTop == true) || effect.orientation == "top") {
193
+ // top orientation
194
+ var ntop = parseInt(positionTop,10) - parseInt(menuHeight,10);
195
+ $(m).addClass("topOriented");
196
+
197
+ } else {
198
+ // bottom orientation
199
+ $(m).addClass("bottomOriented");
200
+ if (effect.yposition == "auto" && effect.xposition == "left") {
201
+ positionTop = positionTop + $(el).outerHeight();
202
+ }
203
+ var ntop = parseInt(positionTop,10);
204
+ }
205
+
206
+ $(m).css({"top":ntop+"px", "left":nleft+"px"});
207
+ }
208
+
209
+ /* show menu depends to effect.show */
210
+ function showMenu() {
211
+
212
+ if (!effect || effect.show == "default") {
213
+ $(m).show();
214
+ return false;
215
+ }
216
+
217
+ var speed = parseInt(effect.speed);
218
+ speed = isNaN(speed) ? 500 : speed;
219
+
220
+ switch (effect.show)
221
+ {
222
+ case "fadeIn":
223
+ $(m).fadeIn(speed);
224
+ break;
225
+
226
+ case "slideDown":
227
+ $(m).slideDown(speed);
228
+ break;
229
+
230
+ default:
231
+ $(m).show();
232
+ break;
233
+ }
234
+ }
235
+
236
+ /* put item to menu */
237
+ function putItem(n) {
238
+
239
+ var item = document.createElement('div');
240
+ $(item).hover(function(){
241
+ $(this).addClass("jj_menu_item_hover")
242
+ },
243
+ function(){
244
+ $(this).removeClass("jj_menu_item_hover")
245
+ });
246
+
247
+ $(item).click( function(event) {
248
+ event.stopPropagation();
249
+ doAction(n.action);
250
+ });
251
+
252
+ var span = document.createElement('span');
253
+ $(item).append(span);
254
+
255
+
256
+ switch (n.type)
257
+ {
258
+ case "sub":
259
+ item.className = "jj_menu_item jj_menu_item_more";
260
+ $(item).click(function() {
261
+ if ($("#jjmenu_"+id+"_sub").length > 0) {
262
+ $("div[id^=jjmenu_"+id+"_sub]").remove();
263
+ }
264
+ else {
265
+ var sub = new menu(id+"_sub", n.src, myReplaces, this, effect);
266
+ }
267
+ });
268
+ break;
269
+
270
+ default:
271
+ $(item).hover(function() { $("div[id^=jjmenu_"+id+"_sub]").remove(); });
272
+ item.className = "jj_menu_item";
273
+ break;
274
+ }
275
+
276
+
277
+ if (n.customClass && n.customClass.length>0) {
278
+ jQuery(span).addClass(n.customClass);
279
+ }
280
+
281
+ $(span).html(uReplace(n.title));
282
+ $(ms).append(item);
283
+ }
284
+
285
+ /* do action on menu item */
286
+ function doAction(act) {
287
+
288
+ if (act) {
289
+
290
+ switch (act.type) {
291
+
292
+ case "gourl":
293
+ if (act.target) {
294
+ var newWindow = window.open(uReplace(act.url), act.target);
295
+ newWindow.focus();
296
+ return false;
297
+ }
298
+ else {
299
+ document.location.href=uReplace(act.url);
300
+ }
301
+ break;
302
+
303
+ case "ajax":
304
+ $.getJSON(uReplace(act.url), function(data) {
305
+
306
+ var cb = eval(act.callback);
307
+ if (typeof(cb) == "function") {
308
+ cb(data);
309
+ }
310
+
311
+ });
312
+ break;
313
+
314
+ case "fn":
315
+ var callfn = 'var cb = '+act.callback;
316
+ jQuery.globalEval(callfn);
317
+ if (typeof(cb) == "function") {
318
+ cb(myReplaces);
319
+ }
320
+ break;
321
+
322
+ /*
323
+ addition to allow function to execute in expected
324
+ context and remove menu after callback executes
325
+ JGF - 2011-08-15
326
+ */
327
+ case "xfn":
328
+ act.callback(myReplaces);
329
+ $("#jjmenu_main").remove();
330
+ break;
331
+ }
332
+ }
333
+ }
334
+
335
+ /* replace string with user parameters */
336
+ function uReplace(str) {
337
+ if (myReplaces) {
338
+ for (var u in myReplaces) {
339
+ str = str.replace("#"+u+"#", eval("myReplaces."+u));
340
+ }
341
+ }
342
+ return str;
343
+ }
344
+
345
+ /* get effect opbject */
346
+ function getEffect(id, effect) {
347
+
348
+ var defEffect = {
349
+ show:"default",
350
+ xposition:"right",
351
+ yposition:"auto",
352
+ orientation:"auto"
353
+ };
354
+
355
+ if (!effect) { return defEffect; }
356
+
357
+ if (!effect.show) effect.show = "default";
358
+
359
+ var show = effect.show;
360
+
361
+ if (!effect.xposition) effect.xposition = "right";
362
+ if (!effect.yposition) effect.yposition = "auto";
363
+ if (!effect.orientation) effect.orientation = "auto";
364
+
365
+ if (id != "main") {
366
+ var subeffect = defEffect;
367
+ subeffect.show = show;
368
+ }
369
+
370
+ return ( id == "main" ) ? effect : subeffect;
371
+ }
372
+ } // !menu
373
+ };
374
+
375
+ })(jQuery);