redcar 0.9.2 → 0.10

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 (234) hide show
  1. data/CHANGES +34 -4
  2. data/Rakefile +2 -1
  3. data/lib/redcar.rb +3 -3
  4. data/lib/redcar/installer.rb +2 -3
  5. data/plugins/application/features/step_definitions/dialog_steps.rb +7 -0
  6. data/plugins/application/features/step_definitions/key_steps.rb +18 -0
  7. data/plugins/application/features/step_definitions/menu_steps.rb +5 -6
  8. data/plugins/application/features/step_definitions/speedbar_steps.rb +29 -9
  9. data/plugins/application/features/step_definitions/tree_steps.rb +13 -0
  10. data/plugins/application/features/support/env.rb +39 -5
  11. data/plugins/application/features/support/fake_event.rb +12 -0
  12. data/plugins/application/lib/application.rb +5 -6
  13. data/plugins/application/lib/application/dialog.rb +53 -10
  14. data/plugins/application/lib/application/dialogs/modeless_list_dialog.rb +85 -0
  15. data/plugins/application/lib/application/keymap.rb +10 -8
  16. data/plugins/application/lib/application/menu.rb +38 -16
  17. data/plugins/application/lib/application/treebook.rb +30 -0
  18. data/plugins/application/lib/application/window.rb +20 -2
  19. data/plugins/application/spec/application/command/executor_spec.rb +1 -0
  20. data/plugins/application/spec/application/menu_spec.rb +26 -26
  21. data/plugins/application/spec/application/treebook_spec.rb +6 -6
  22. data/plugins/application/spec/spec_helper.rb +10 -1
  23. data/plugins/application_swt/lib/application_swt.rb +25 -3
  24. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +48 -27
  25. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +22 -11
  26. data/plugins/application_swt/lib/application_swt/dialogs/modeless_dialog.rb +113 -0
  27. data/plugins/application_swt/lib/application_swt/dialogs/modeless_html_dialog.rb +85 -0
  28. data/plugins/application_swt/lib/application_swt/dialogs/modeless_list_dialog_controller.rb +143 -0
  29. data/plugins/application_swt/lib/application_swt/gradient.rb +61 -0
  30. data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +4 -4
  31. data/plugins/application_swt/lib/application_swt/notebook.rb +5 -8
  32. data/plugins/application_swt/lib/application_swt/speedbar.rb +1 -0
  33. data/plugins/application_swt/lib/application_swt/treebook.rb +6 -8
  34. data/plugins/application_swt/lib/application_swt/window.rb +85 -57
  35. data/plugins/application_swt/lib/swt/graphics_utils.rb +23 -0
  36. data/plugins/application_swt/lib/swt/vtab_folder.rb +7 -0
  37. data/plugins/application_swt/lib/swt/vtab_label.rb +1 -1
  38. data/plugins/application_swt/spec/application_swt/gradient_spec.rb +142 -0
  39. data/plugins/auto_completer/lib/auto_completer.rb +10 -42
  40. data/plugins/auto_completer/lib/auto_completer/list_dialog.rb +21 -0
  41. data/plugins/clojure/lib/clojure.rb +33 -0
  42. data/plugins/{repl/lib/repl/clojure_mirror.rb → clojure/lib/clojure/repl_mirror.rb} +16 -20
  43. data/plugins/clojure/plugin.rb +9 -0
  44. data/plugins/{repl/spec/repl/clojure_mirror_spec.rb → clojure/spec/clojure/repl_mirror_spec.rb} +12 -13
  45. data/plugins/clojure/spec/spec_helper.rb +5 -0
  46. data/plugins/{repl → clojure}/vendor/Wrapper.clj +0 -0
  47. data/plugins/{repl → clojure}/vendor/dummy +0 -0
  48. data/plugins/{repl → clojure}/vendor/enclojure-wrapper.jar +0 -0
  49. data/plugins/connection_manager/lib/connection_manager.rb +13 -13
  50. data/plugins/declarations/lib/declarations.rb +17 -6
  51. data/plugins/document_search/features/find.feature +389 -0
  52. data/plugins/document_search/features/find_and_replace.feature +723 -0
  53. data/plugins/document_search/features/replace.feature +69 -62
  54. data/plugins/document_search/lib/document_search.rb +81 -64
  55. data/plugins/document_search/lib/document_search/commands.rb +258 -0
  56. data/plugins/document_search/lib/document_search/find_and_replace_speedbar.rb +142 -0
  57. data/plugins/document_search/lib/document_search/find_speedbar.rb +102 -0
  58. data/plugins/document_search/lib/document_search/query_options.rb +45 -0
  59. data/plugins/edit_view/features/case_change.feature +9 -5
  60. data/plugins/edit_view/features/step_definitions/editing_steps.rb +19 -0
  61. data/plugins/edit_view/lib/edit_view.rb +15 -12
  62. data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +12 -2
  63. data/plugins/edit_view/lib/edit_view/commands/text_conversion_commands.rb +1 -1
  64. data/plugins/edit_view/lib/edit_view/document.rb +129 -99
  65. data/plugins/edit_view_swt/lib/edit_view_swt.rb +33 -15
  66. data/plugins/encryption/encryption.rb +2 -0
  67. data/plugins/find-in-project/lib/find_in_project.rb +3 -5
  68. data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +2 -0
  69. data/plugins/groovy/features/step_definitions/groovy_steps.rb +2 -2
  70. data/plugins/groovy/features/syntax_check_groovy.feature +3 -3
  71. data/plugins/groovy/lib/groovy.rb +38 -0
  72. data/plugins/groovy/lib/groovy/commands.rb +10 -0
  73. data/plugins/{repl/lib/repl/groovy_mirror.rb → groovy/lib/groovy/repl_mirror.rb} +33 -13
  74. data/plugins/groovy/lib/{syntax_check/groovy.rb → groovy/syntax_checker.rb} +13 -8
  75. data/plugins/groovy/plugin.rb +5 -4
  76. data/plugins/{repl/spec/repl/groovy_mirror_spec.rb → groovy/spec/groovy/repl_mirror_spec.rb} +14 -13
  77. data/plugins/groovy/spec/spec_helper.rb +5 -0
  78. data/plugins/html_view/assets/json2.js +476 -0
  79. data/plugins/html_view/lib/html_view.rb +1 -0
  80. data/plugins/java/features/fixtures/test.java +0 -0
  81. data/plugins/java/features/support/env.rb +27 -0
  82. data/plugins/java/features/syntax_check_java.feature +86 -0
  83. data/plugins/java/lib/syntax_check/java.rb +86 -0
  84. data/plugins/java/plugin.rb +7 -0
  85. data/plugins/javascript/features/fixtures/test2.js +5 -0
  86. data/plugins/javascript/features/step_definitions/javascript_steps.rb +16 -0
  87. data/plugins/javascript/features/support/env.rb +14 -0
  88. data/plugins/javascript/features/syntax_check_javascript.feature +46 -3
  89. data/plugins/javascript/lib/syntax_check/javascript.rb +15 -9
  90. data/plugins/line_tools/features/trim_line.feature +49 -0
  91. data/plugins/line_tools/lib/line_tools.rb +5 -1
  92. data/plugins/mirah/README +7 -0
  93. data/plugins/mirah/features/fixtures/test.mirah +2 -0
  94. data/plugins/mirah/features/syntax_check_mirah.feature +46 -0
  95. data/plugins/mirah/lib/mirah.rb +43 -0
  96. data/plugins/mirah/lib/mirah/my_error_handler.rb +22 -0
  97. data/plugins/mirah/lib/mirah/repl_mirror.rb +50 -0
  98. data/plugins/mirah/lib/mirah/syntax_checker.rb +38 -0
  99. data/plugins/mirah/plugin.rb +8 -0
  100. data/plugins/mirah/spec/mirah/repl_mirror_spec.rb +188 -0
  101. data/plugins/mirah/spec/spec_helper.rb +5 -0
  102. data/plugins/mirah/vendor/mirah-parser.jar +0 -0
  103. data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +24 -23
  104. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +10 -1
  105. data/plugins/plugin_manager_ui/views/index.html.erb +2 -0
  106. data/plugins/project/features/find_file.feature +40 -16
  107. data/plugins/project/features/highlight_focussed_tab.feature +16 -10
  108. data/plugins/project/features/step_definitions/find_file_steps.rb +11 -0
  109. data/plugins/project/features/step_definitions/project_tree_steps.rb +5 -1
  110. data/plugins/project/features/support/env.rb +5 -0
  111. data/plugins/project/lib/project/commands.rb +8 -1
  112. data/plugins/project/lib/project/dir_controller.rb +4 -1
  113. data/plugins/project/lib/project/find_file_dialog.rb +16 -12
  114. data/plugins/project/lib/project/manager.rb +30 -1
  115. data/plugins/project_search/vendor/lucene/CHANGELOG +147 -0
  116. data/plugins/project_search/vendor/lucene/CONTRIBUTORS +17 -0
  117. data/plugins/project_search/vendor/lucene/Gemfile +9 -0
  118. data/plugins/project_search/vendor/lucene/Gemfile.lock +33 -0
  119. data/plugins/project_search/vendor/lucene/LICENSE +19 -0
  120. data/plugins/project_search/vendor/lucene/README.rdoc +283 -0
  121. data/plugins/project_search/vendor/lucene/Rakefile +35 -0
  122. data/plugins/project_search/vendor/lucene/examples/active_model/serializers.rb +25 -0
  123. data/plugins/project_search/vendor/lucene/examples/active_model/validation.rb +26 -0
  124. data/plugins/project_search/vendor/lucene/examples/admin/Rakefile +4 -0
  125. data/plugins/project_search/vendor/lucene/examples/admin/admin.rb +29 -0
  126. data/plugins/project_search/vendor/lucene/examples/admin/public/jquery.js +4376 -0
  127. data/plugins/project_search/vendor/lucene/examples/admin/public/neo4j.css +153 -0
  128. data/plugins/project_search/vendor/lucene/examples/admin/public/neo_admin.js +18 -0
  129. data/plugins/project_search/vendor/lucene/examples/admin/spec/admin_spec.rb +26 -0
  130. data/plugins/project_search/vendor/lucene/examples/admin/views/index.erb +21 -0
  131. data/plugins/project_search/vendor/lucene/examples/filetree/README.rdoc +9 -0
  132. data/plugins/project_search/vendor/lucene/examples/filetree/app.rb +7 -0
  133. data/plugins/project_search/vendor/lucene/examples/filetree/batch.props +5 -0
  134. data/plugins/project_search/vendor/lucene/examples/filetree/features/step_definitions/add_steps.rb +121 -0
  135. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/env.rb +30 -0
  136. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/rspec_helper.rb +50 -0
  137. data/plugins/project_search/vendor/lucene/examples/filetree/features/treesizes.feature +19 -0
  138. data/plugins/project_search/vendor/lucene/examples/imdb/1_create_neo_db.rb +66 -0
  139. data/plugins/project_search/vendor/lucene/examples/imdb/2_index_db.rb +23 -0
  140. data/plugins/project_search/vendor/lucene/examples/imdb/README +12 -0
  141. data/plugins/project_search/vendor/lucene/examples/imdb/find_actors.rb +56 -0
  142. data/plugins/project_search/vendor/lucene/examples/imdb/install.sh +12 -0
  143. data/plugins/project_search/vendor/lucene/examples/imdb/model.rb +37 -0
  144. data/plugins/project_search/vendor/lucene/examples/railway/README +111 -0
  145. data/plugins/project_search/vendor/lucene/examples/railway/railnet-app.rb +31 -0
  146. data/plugins/project_search/vendor/lucene/examples/railway/railnet-data.rb +42 -0
  147. data/plugins/project_search/vendor/lucene/examples/rest/example.rb +41 -0
  148. data/plugins/project_search/vendor/lucene/examples/you_might_know/YouMightKnow.java +60 -0
  149. data/plugins/project_search/vendor/lucene/examples/you_might_know/all_simple_paths.rb +34 -0
  150. data/plugins/project_search/vendor/lucene/examples/you_might_know/nodes.rb +34 -0
  151. data/plugins/project_search/vendor/lucene/examples/you_might_know/you_might_know.rb +50 -0
  152. data/plugins/project_search/vendor/lucene/lib/lucene.rb +15 -0
  153. data/plugins/project_search/vendor/lucene/lib/lucene/config.rb +145 -0
  154. data/plugins/project_search/vendor/lucene/lib/lucene/document.rb +96 -0
  155. data/plugins/project_search/vendor/lucene/lib/lucene/field_info.rb +144 -0
  156. data/plugins/project_search/vendor/lucene/lib/lucene/hits.rb +54 -0
  157. data/plugins/project_search/vendor/lucene/lib/lucene/index.rb +267 -0
  158. data/plugins/project_search/vendor/lucene/lib/lucene/index_info.rb +146 -0
  159. data/plugins/project_search/vendor/lucene/lib/lucene/index_searcher.rb +157 -0
  160. data/plugins/project_search/vendor/lucene/lib/lucene/jars.rb +5 -0
  161. data/plugins/project_search/vendor/lucene/lib/lucene/query_dsl.rb +135 -0
  162. data/plugins/project_search/vendor/lucene/lib/lucene/transaction.rb +117 -0
  163. data/plugins/project_search/vendor/lucene/lib/lucene/version.rb +3 -0
  164. data/plugins/project_search/vendor/lucene/lucene.gemspec +23 -0
  165. data/plugins/project_search/vendor/lucene/spec/lucene/document_spec.rb +32 -0
  166. data/plugins/project_search/vendor/lucene/spec/lucene/field_info_spec.rb +70 -0
  167. data/plugins/project_search/vendor/lucene/spec/lucene/index_info_spec.rb +76 -0
  168. data/plugins/project_search/vendor/lucene/spec/lucene/index_spec.rb +643 -0
  169. data/plugins/project_search/vendor/lucene/spec/lucene/query_dsl_spec.rb +142 -0
  170. data/plugins/project_search/vendor/lucene/spec/lucene/sort_spec.rb +101 -0
  171. data/plugins/project_search/vendor/lucene/spec/lucene/spec_helper.rb +10 -0
  172. data/plugins/project_search/vendor/lucene/spec/lucene/transaction_spec.rb +118 -0
  173. data/plugins/redcar/features/alter_font_size.feature +25 -0
  174. data/plugins/redcar/features/step_definitions/font_steps.rb +34 -0
  175. data/plugins/redcar/redcar.rb +256 -43
  176. data/plugins/repl/features/command_editing.feature +55 -0
  177. data/plugins/repl/features/command_history.feature +75 -0
  178. data/plugins/repl/features/step_definitions/repl_steps.rb +17 -1
  179. data/plugins/repl/features/support/env.rb +24 -0
  180. data/plugins/repl/features/support/fake_repl.rb +16 -0
  181. data/plugins/repl/lib/repl.rb +17 -74
  182. data/plugins/repl/lib/repl/repl_command.rb +20 -0
  183. data/plugins/repl/lib/repl/repl_mirror.rb +168 -22
  184. data/plugins/repl/lib/repl/repl_tab.rb +131 -6
  185. data/plugins/repl/plugin.rb +1 -1
  186. data/plugins/repl/spec/repl/repl_mirror_spec.rb +72 -0
  187. data/plugins/repl/spec/spec_helper.rb +1 -1
  188. data/plugins/repl_swt/lib/repl_swt.rb +7 -0
  189. data/plugins/repl_swt/lib/repl_swt/key_listener.rb +43 -0
  190. data/plugins/repl_swt/plugin.rb +8 -0
  191. data/plugins/ruby/lib/ruby.rb +35 -0
  192. data/plugins/{repl/lib/repl/ruby_mirror.rb → ruby/lib/ruby/repl_mirror.rb} +12 -12
  193. data/plugins/ruby/lib/{syntax_check/ruby.rb → ruby/syntax_checker.rb} +3 -3
  194. data/plugins/ruby/plugin.rb +5 -4
  195. data/plugins/{repl/spec/repl/ruby_mirror_spec.rb → ruby/spec/ruby/repl_mirror_spec.rb} +38 -29
  196. data/plugins/ruby/spec/spec_helper.rb +5 -0
  197. data/plugins/runnables/lib/runnables.rb +2 -0
  198. data/plugins/runnables/lib/runnables/command_output_controller.rb +5 -0
  199. data/plugins/runnables/lib/runnables/output_processor.rb +14 -3
  200. data/plugins/runnables/views/command_output.html.erb +3 -2
  201. data/plugins/scm/lib/scm.rb +4 -2
  202. data/plugins/scm/lib/scm/diff_mirror.rb +6 -6
  203. data/plugins/scm_git/lib/scm_git.rb +136 -107
  204. data/plugins/scm_git/lib/scm_git/change.rb +28 -19
  205. data/plugins/snippets/lib/snippets/explorer.rb +2 -2
  206. data/plugins/swt/lib/swt/full_swt.rb +1 -0
  207. data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +4 -0
  208. data/plugins/syntax_check/features/support/env.rb +3 -0
  209. data/plugins/syntax_check/lib/syntax_check.rb +71 -5
  210. data/plugins/syntax_check/lib/syntax_check/annotation.rb +61 -0
  211. data/plugins/test_runner/lib/test_runner.rb +39 -0
  212. data/plugins/test_runner/lib/test_runner/rspec_runner.rb +20 -0
  213. data/plugins/test_runner/lib/test_runner/run_test_command.rb +63 -0
  214. data/plugins/test_runner/lib/test_runner/runnable_test_runner.rb +26 -0
  215. data/plugins/test_runner/plugin.rb +8 -0
  216. data/plugins/test_runner/spec/run_test_command_spec.rb +51 -0
  217. data/plugins/test_runner/spec/spec_helper.rb +5 -0
  218. data/plugins/textmate/lib/textmate.rb +12 -2
  219. data/plugins/textmate/vendor/redcar-bundles/Bundles/HTML.tmbundle/Syntaxes/HTML.plist +0 -2
  220. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/Syntaxes/Mirah.plist +22 -0
  221. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/info.plist +12 -0
  222. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby.tmbundle/Syntaxes/Ruby.plist +2 -0
  223. data/plugins/todo_list/lib/todo_list.rb +7 -0
  224. data/plugins/todo_list/lib/todo_list/todo_controller.rb +3 -1
  225. data/plugins/tree/lib/tree.rb +4 -0
  226. data/plugins/tree_view_swt/lib/tree_view_swt.rb +5 -0
  227. data/plugins/web_bookmarks/lib/web_bookmarks.rb +10 -0
  228. metadata +137 -22
  229. data/plugins/document_search/features/search.feature +0 -163
  230. data/plugins/document_search/lib/document_search/replace_all_command.rb +0 -27
  231. data/plugins/document_search/lib/document_search/replace_command.rb +0 -38
  232. data/plugins/document_search/lib/document_search/replace_next_command.rb +0 -27
  233. data/plugins/document_search/lib/document_search/search_and_replace.rb +0 -81
  234. data/plugins/ruby/README +0 -6
@@ -0,0 +1,143 @@
1
+
2
+ module Redcar
3
+ class ApplicationSWT
4
+ class ModelessListDialogController
5
+
6
+ DEFAULT_HEIGHT_IN_ROWS = 4
7
+ DEFAULT_WIDTH = 300
8
+
9
+ def initialize(model)
10
+ @model = model
11
+ parent = ApplicationSWT.display
12
+ @shell = Swt::Widgets::Shell.new(parent, Swt::SWT::MODELESS)
13
+ @list = Swt::Widgets::List.new(@shell, Swt::SWT::V_SCROLL | Swt::SWT::SINGLE)
14
+ layout = Swt::Layout::GridLayout.new(1, true)
15
+ layout.marginHeight = 0
16
+ layout.marginWidth = 0
17
+ layout.verticalSpacing = 0
18
+ @shell.setLayout(layout)
19
+ @list.set_layout_data(Swt::Layout::GridData.new(Swt::Layout::GridData::FILL_BOTH))
20
+ @key_listener = KeyListener.new(@model)
21
+ if @model.close_on_lost_focus
22
+ @focus_listener = FocusListener.new(@model)
23
+ @list.add_focus_listener(@focus_listener)
24
+ end
25
+ @list.add_key_listener(@key_listener)
26
+ @shell.pack
27
+ @shell.set_size DEFAULT_WIDTH, convert_to_pixels(DEFAULT_HEIGHT_IN_ROWS)
28
+ attach_listeners
29
+ end
30
+
31
+ def set_size(width,height)
32
+ @shell.set_size width, convert_to_pixels(height)
33
+ end
34
+
35
+ def convert_to_pixels(rows)
36
+ @list.get_item_height * rows
37
+ end
38
+
39
+ def set_location(offset)
40
+ x, y = Swt::GraphicsUtils.below_pixel_location_at_offset(offset)
41
+ @shell.set_location(x,y) if x and y
42
+ end
43
+
44
+ # Item at a particular index
45
+ def select(index)
46
+ items = @list.get_items
47
+ if items.size > index and index >= 0
48
+ item = items[index]
49
+ item = item[2,item.length] if item =~ /^(\d)\s.*/
50
+ end
51
+ item
52
+ end
53
+
54
+ # The currently selected value
55
+ def selection_value
56
+ @list.get_selection.first
57
+ end
58
+
59
+ # Zero-based selected index
60
+ def selection_index
61
+ @list.get_selection_index
62
+ end
63
+
64
+ # Close the dialog
65
+ def close
66
+ @list.remove_key_listener(@key_listener)
67
+ @list.remove_focus_listener(@focus_listener) if @focus_listener
68
+ @shell.dispose
69
+ end
70
+
71
+ # Open the dialog
72
+ def open
73
+ ApplicationSWT.register_shell(@shell)
74
+ @shell.open
75
+ end
76
+
77
+ # Update the list items
78
+ #
79
+ # @param [Array<String>] items
80
+ def update_list(items)
81
+ (0..9).each do |i|
82
+ items[i] = "#{i+1} #{items[i]}" if items.size > i
83
+ end
84
+ @list.set_items items
85
+ end
86
+
87
+ def attach_listeners
88
+ @model.add_listener(:open, &method(:open))
89
+ @model.add_listener(:close, &method(:close))
90
+ @model.add_listener(:set_location, &method(:set_location))
91
+ @model.add_listener(:set_size, &method(:set_size))
92
+ @model.add_listener(:update_list, &method(:update_list))
93
+ end
94
+
95
+ class KeyListener
96
+
97
+ def initialize(model)
98
+ @model = model
99
+ end
100
+
101
+ def key_pressed(e)
102
+ case e.keyCode
103
+ when Swt::SWT::CR, Swt::SWT::LF
104
+ index = @model.selection_index
105
+ @model.selected(index)
106
+ when Swt::SWT::ARROW_RIGHT
107
+ items = @model.next_list
108
+ @model.update_list(items) if items
109
+ when Swt::SWT::ARROW_LEFT
110
+ items = @model.previous_list
111
+ @model.update_list(items) if items
112
+ when Swt::SWT::ESC
113
+ @model.close
114
+ else
115
+ (0..9).each do |i|
116
+ if e.keyCode == Swt::SWT.const_get("KEYPAD_#{i}") or
117
+ e.keyCode == i + 48
118
+ @model.selected(i - 1)
119
+ break
120
+ end
121
+ end
122
+ end
123
+ end
124
+
125
+ def key_released(e)
126
+ end
127
+ end
128
+
129
+ class FocusListener
130
+ def initialize(model)
131
+ @model = model
132
+ end
133
+
134
+ def focus_gained(e)
135
+ end
136
+
137
+ def focus_lost(e)
138
+ @model.close
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,61 @@
1
+ module Redcar
2
+ class ApplicationSWT
3
+ class Gradient
4
+ # Expects a hash with gradient color locations from 1-100 as keys
5
+ # and 6-character hex RGB strings as values
6
+ def initialize(color_stops_or_solid_color)
7
+ if color_stops_or_solid_color.is_a?(String)
8
+ color_stops = {100 => color_stops_or_solid_color}
9
+ else
10
+ color_stops = color_stops_or_solid_color
11
+ end
12
+
13
+ raise ArgumentError, "Color stops must be in the range 0-100" if color_stops.any? { |position, color| (position < 0) || (position > 100) }
14
+ @color_stops = color_stops
15
+ make_start_and_end_stops_explicit!
16
+ end
17
+
18
+ def to_hash
19
+ @color_stops
20
+ end
21
+
22
+ def swt_stops
23
+ stops_with_implicit_zero = @color_stops.keys.sort - [0]
24
+ stops_with_implicit_zero.to_java(:int)
25
+ end
26
+
27
+ def swt_colors
28
+ hex_rgb_strings = @color_stops.sort.map { |position, color| color }
29
+ swt_colors = hex_rgb_strings.map do |hex_rgb_string|
30
+ if hex_rgb_string =~ /^ (\W+)? ([0-9A-Fa-f]{3}{1,2}) (\W+)? $/x
31
+ hex_string = Regexp.last_match.captures[1]
32
+ if(hex_string.size == 3) # Shorthand
33
+ hex_string = hex_string.split('').map{ |hex_string| hex_string * 2 }.join('')
34
+ end
35
+
36
+ color_components = hex_string.scan(/.{2}/)
37
+ int_components = color_components.map { |component| component.to_i(16) }
38
+ Swt::Graphics::Color.new(ApplicationSWT.display, *int_components[0...3])
39
+
40
+ elsif Swt::SWT.const_defined?(const_name = "COLOR_#{ hex_rgb_string.upcase }")
41
+ swt_const = Swt::SWT.const_get(const_name)
42
+ ApplicationSWT.display.get_system_color(swt_const)
43
+
44
+ else
45
+ raise "Colors must be RGB hex strings or SWT color names"
46
+ end
47
+ end
48
+
49
+ swt_colors.to_java(Swt::Graphics::Color)
50
+ end
51
+
52
+ private
53
+
54
+ def make_start_and_end_stops_explicit!
55
+ @color_stops[0] ||= @color_stops[@color_stops.keys.min]
56
+ @color_stops[100] ||= @color_stops[@color_stops.keys.max]
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -28,14 +28,14 @@ module Redcar
28
28
  value += " "[0]
29
29
  elsif key_string =~ /(F\d+)/
30
30
  value += Swt::SWT.const_get $1
31
- elsif key_string =~ /(Right|Left|Up|Down)/
32
- value += Swt::SWT.const_get 'ARROW_'+$1.upcase
33
- elsif key_string =~ /Tab/
34
- value += Swt::SWT::TAB
35
31
  elsif key_string =~ /Page Up$/
36
32
  value += Swt::SWT::PAGE_UP
37
33
  elsif key_string =~ /Page Down$/
38
34
  value += Swt::SWT::PAGE_DOWN
35
+ elsif key_string =~ /(Right|Left|Up|Down)/
36
+ value += Swt::SWT.const_get 'ARROW_'+$1.upcase
37
+ elsif key_string =~ /Tab/
38
+ value += Swt::SWT::TAB
39
39
  elsif key_string =~ /Home$/
40
40
  value += Swt::SWT::HOME
41
41
  elsif key_string =~ /End$/
@@ -80,14 +80,11 @@ module Redcar
80
80
  end
81
81
 
82
82
  def style_tab_folder
83
- colors = [
84
- Swt::Graphics::Color.new(ApplicationSWT.display, 230, 240, 255),
85
- Swt::Graphics::Color.new(ApplicationSWT.display, 170, 199, 246),
86
- Swt::Graphics::Color.new(ApplicationSWT.display, 135, 178, 247)
87
- ].to_java(Swt::Graphics::Color)
88
- percents = [60, 85].to_java(:int)
89
-
90
- @tab_folder.setSelectionBackground(colors, percents, true)
83
+ selected_tab_background = Redcar::ApplicationSWT.selected_tab_background
84
+ @tab_folder.set_selection_background(selected_tab_background.swt_colors, selected_tab_background.swt_stops, true)
85
+
86
+ unselected_tab_background = Redcar::ApplicationSWT.unselected_tab_background
87
+ @tab_folder.set_background(unselected_tab_background.swt_colors, unselected_tab_background.swt_stops, true)
91
88
  end
92
89
 
93
90
  def attach_model_listeners
@@ -45,6 +45,7 @@ module Redcar
45
45
  end
46
46
 
47
47
  def num_columns
48
+ return @model.num_columns if @model.respond_to?(:num_columns)
48
49
  @model.__items.select {|i| !i.is_a?(Redcar::Speedbar::KeyItem) }.length
49
50
  end
50
51
 
@@ -38,13 +38,12 @@ module Redcar
38
38
 
39
39
  def create_tree_view
40
40
  @tab_folder = Swt::Widgets::VTabFolder.new(@window.tree_sash, Swt::SWT::NONE)
41
- colors = [
42
- Swt::Graphics::Color.new(ApplicationSWT.display, 230, 240, 255),
43
- Swt::Graphics::Color.new(ApplicationSWT.display, 170, 199, 246),
44
- Swt::Graphics::Color.new(ApplicationSWT.display, 135, 178, 247)
45
- ]
46
- percents = [60, 85]
47
- @tab_folder.set_selection_background(colors, percents, true)
41
+
42
+ selected_tab_background = Redcar::ApplicationSWT.selected_tab_background
43
+ @tab_folder.set_selection_background(selected_tab_background.swt_colors, selected_tab_background.swt_stops, true)
44
+
45
+ unselected_tab_background = Redcar::ApplicationSWT.unselected_tab_background
46
+ @tab_folder.set_background(unselected_tab_background.swt_colors, unselected_tab_background.swt_stops, true)
48
47
 
49
48
  attach_view_listeners
50
49
 
@@ -71,4 +70,3 @@ module Redcar
71
70
  end
72
71
  end
73
72
  end
74
-
@@ -3,40 +3,40 @@ module Redcar
3
3
  class ApplicationSWT
4
4
  class Window
5
5
  attr_reader :shell, :window
6
-
6
+
7
7
  SASH_WIDTH = 5
8
8
  TREEBOOK_WIDTH = 200
9
9
  MINIMUM_TREEBOOK_WIDTH = 0
10
10
  VISIBLE_TREEBOOK_WIDTH = 25
11
11
  TOOLBAR_HEIGHT = 25
12
12
  @toolbar_height = 30
13
-
13
+
14
14
  class ShellListener
15
15
  include org.eclipse.swt.events.ShellListener
16
-
16
+
17
17
  def initialize(controller)
18
18
  @win = controller.window
19
19
  end
20
-
20
+
21
21
  def shell_closed(e)
22
22
  unless Redcar.app.events.ignore?(:window_close, @win)
23
23
  e.doit = false
24
24
  Redcar.app.events.create(:window_close, @win)
25
25
  end
26
26
  end
27
-
27
+
28
28
  def shell_activated(e)
29
29
  unless Redcar.app.events.ignore?(:window_focus, @win)
30
30
  e.doit = false
31
31
  Redcar.app.events.create(:window_focus, @win)
32
32
  end
33
33
  end
34
-
34
+
35
35
  def shell_deactivated(_); end
36
36
  def shell_deiconified(_); end
37
37
  def shell_iconified(_); end
38
38
  end
39
-
39
+
40
40
  def initialize(window)
41
41
  @window = window
42
42
  @notebook_handlers = Hash.new {|h,k| h[k] = []}
@@ -49,7 +49,7 @@ module Redcar
49
49
  @treebook_unopened = true
50
50
  set_icon
51
51
  end
52
-
52
+
53
53
  def add_listeners
54
54
  @window.add_listener(:show, &method(:show))
55
55
  @window.add_listener(:refresh_menu, &method(:refresh_menu))
@@ -65,7 +65,11 @@ module Redcar
65
65
  @window.add_listener(:focussed, &method(:focussed))
66
66
  @window.add_listener(:speedbar_opened, &method(:speedbar_opened))
67
67
  @window.add_listener(:speedbar_closed, &method(:speedbar_closed))
68
-
68
+ @window.add_listener(:enlarge_notebook, &method(:enlarge_notebook))
69
+ @window.add_listener(:reset_notebook_widths, &method(:reset_notebook_sash_widths))
70
+ @window.add_listener(:increase_treebook_width, &method(:increase_treebook_width))
71
+ @window.add_listener(:decrease_treebook_width, &method(:decrease_treebook_width))
72
+
69
73
  @window.add_listener(:toggle_trees_visible, &method(:toggle_sash_widths))
70
74
  @window.treebook.add_listener(:tree_added) do
71
75
  if @treebook_unopened or not @window.trees_visible?
@@ -79,38 +83,38 @@ module Redcar
79
83
  @treebook_unopened = false
80
84
  end
81
85
  end
82
-
86
+
83
87
  @window.treebook.add_listener(:tree_removed) do
84
88
  reset_sash_widths
85
89
  end
86
90
  @shell.add_key_listener(KeyListener.new(self))
87
91
  end
88
-
92
+
89
93
  def treebook_hidden?
90
94
  treebook_width <= VISIBLE_TREEBOOK_WIDTH
91
95
  end
92
-
96
+
93
97
  def treebook_width
94
98
  @sash.layout_data.left.offset
95
99
  end
96
-
100
+
97
101
  def default_treebook_width
98
102
  TREEBOOK_WIDTH + SASH_WIDTH
99
103
  end
100
-
104
+
101
105
  def fullscreen
102
106
  @shell.fullScreen()
103
107
  end
104
-
108
+
105
109
  def fullscreen=(value)
106
110
  @shell.setFullScreen(value)
107
111
  end
108
-
112
+
109
113
  class KeyListener
110
114
  def initialize(edit_view_swt)
111
115
  @edit_view_swt = edit_view_swt
112
116
  end
113
-
117
+
114
118
  def key_pressed(key_event)
115
119
  p key_event
116
120
  if key_event.character == Swt::SWT::TAB
@@ -119,7 +123,7 @@ module Redcar
119
123
  p :esc_pressedwin
120
124
  end
121
125
  end
122
-
126
+
123
127
  def verify_key(key_event)
124
128
  p :verkey
125
129
  if key_event.character == Swt::SWT::TAB
@@ -127,11 +131,11 @@ module Redcar
127
131
  key_event.doit = false
128
132
  end
129
133
  end
130
-
134
+
131
135
  def key_released(key_event)
132
136
  end
133
137
  end
134
-
138
+
135
139
  def create_treebook_controller
136
140
  treebook = @window.treebook
137
141
  controller = ApplicationSWT::Treebook.new(
@@ -139,19 +143,19 @@ module Redcar
139
143
  treebook)
140
144
  treebook.controller = controller
141
145
  end
142
-
146
+
143
147
  def show
144
148
  @shell.open
145
149
  @shell.text = window.title
146
150
  end
147
-
151
+
148
152
  def refresh_menu
149
153
  old_menu_bar = shell.menu_bar
150
154
  @menu_controller = ApplicationSWT::Menu.new(self, Redcar.app.main_menu(@window), Redcar.app.main_keymap, Swt::SWT::BAR)
151
155
  shell.menu_bar = @menu_controller.menu_bar
152
156
  old_menu_bar.dispose if old_menu_bar
153
157
  end
154
-
158
+
155
159
  def refresh_toolbar
156
160
  if Redcar.app.show_toolbar?
157
161
  @toolbar_controller = ApplicationSWT::ToolBar.new(self, Redcar.app.main_toolbar, Swt::SWT::HORIZONTAL | Swt::SWT::BORDER)
@@ -163,11 +167,11 @@ module Redcar
163
167
  end
164
168
  reset_sash_height
165
169
  end
166
-
170
+
167
171
  def set_icon
168
172
  shell.image = Icon.swt_image(icon_file)
169
173
  end
170
-
174
+
171
175
  def icon_file
172
176
  if Redcar::VERSION =~ /dev$/
173
177
  :redcar_icon_beta_dev
@@ -175,7 +179,7 @@ module Redcar
175
179
  :redcar_icon_beta
176
180
  end
177
181
  end
178
-
182
+
179
183
  def bring_to_front
180
184
  @shell.set_minimized(false) # unminimize, just in case
181
185
  @shell.redraw
@@ -186,34 +190,34 @@ module Redcar
186
190
  @shell.force_active # doesn't do anything, really
187
191
  @shell.set_active
188
192
  end
189
-
193
+
190
194
  def popup_menu(menu)
191
195
  menu.controller = ApplicationSWT::Menu.new(self, menu, nil, Swt::SWT::POP_UP)
192
196
  menu.controller.show
193
197
  end
194
-
198
+
195
199
  def popup_menu_with_numbers(menu)
196
200
  menu.controller = ApplicationSWT::Menu.new(self, menu, nil, Swt::SWT::POP_UP, :numbers => true)
197
201
  menu.controller.show
198
202
  end
199
-
203
+
200
204
  def speedbar_opened(speedbar)
201
205
  speedbar.controller = ApplicationSWT::Speedbar.new(@window, right_composite, speedbar)
202
206
  end
203
-
207
+
204
208
  def speedbar_closed(speedbar)
205
209
  speedbar.controller.close
206
210
  end
207
-
211
+
208
212
  def title_changed(new_title)
209
213
  @shell.text = new_title
210
214
  end
211
-
215
+
212
216
  def new_notebook(notebook_model)
213
217
  notebook_controller = ApplicationSWT::Notebook.new(notebook_model, @notebook_sash)
214
218
  reset_notebook_sash_widths
215
219
  end
216
-
220
+
217
221
  def notebook_removed(notebook_model)
218
222
  notebook_controller = notebook_model.controller
219
223
  @notebook_handlers[notebook_model].each do |h|
@@ -222,32 +226,32 @@ module Redcar
222
226
  notebook_controller.dispose
223
227
  reset_notebook_sash_widths
224
228
  end
225
-
229
+
226
230
  def notebook_orientation_changed(new_orientation)
227
231
  orientation = horizontal_vertical(new_orientation)
228
232
  @notebook_sash.setOrientation(orientation)
229
233
  end
230
-
234
+
231
235
  def focussed(_)
232
236
  @shell.set_active
233
237
  end
234
-
238
+
235
239
  def closed(_)
236
240
  @shell.close
237
241
  @menu_controller.close
238
242
  @toolbar_controller.close if @toolbar_controller
239
243
  end
240
-
244
+
241
245
  def dispose
242
246
  @shell.dispose
243
247
  @menu_controller.close
244
248
  @toolbar_controller.close
245
249
  end
246
-
250
+
247
251
  attr_reader :right_composite, :left_composite, :tree_composite, :tree_layout, :tree_sash
248
-
252
+
249
253
  private
250
-
254
+
251
255
  def create_shell
252
256
  @shell = Swt::Widgets::Shell.new(ApplicationSWT.display)
253
257
  @shell.layout = Swt::Layout::FormLayout.new
@@ -260,10 +264,10 @@ module Redcar
260
264
  end
261
265
  ApplicationSWT.register_shell(@shell)
262
266
  end
263
-
267
+
264
268
  def create_sashes(window_model)
265
269
  orientation = horizontal_vertical(window_model.notebook_orientation)
266
-
270
+
267
271
  @left_composite = Swt::Widgets::Composite.new(@shell, Swt::SWT::NONE)
268
272
  @left_composite.layout = Swt::Layout::GridLayout.new(1, false).tap do |l|
269
273
  l.verticalSpacing = 0
@@ -271,9 +275,9 @@ module Redcar
271
275
  l.horizontalSpacing = 0
272
276
  l.marginWidth = 0
273
277
  end
274
-
278
+
275
279
  @sash = Swt::Widgets::Sash.new(@shell, Swt::SWT::VERTICAL)
276
-
280
+
277
281
  @right_composite = Swt::Widgets::Composite.new(@shell, Swt::SWT::NONE)
278
282
  @right_composite.layout = Swt::Layout::GridLayout.new(1, false).tap do |l|
279
283
  l.verticalSpacing = 0
@@ -281,13 +285,13 @@ module Redcar
281
285
  l.horizontalSpacing = 0
282
286
  l.marginWidth = 0
283
287
  end
284
-
288
+
285
289
  @sash.layout_data = Swt::Layout::FormData.new.tap do |d|
286
290
  d.left = Swt::Layout::FormAttachment.new(0, 0)
287
291
  d.top = Swt::Layout::FormAttachment.new(0, 5 + TOOLBAR_HEIGHT)
288
292
  d.bottom = Swt::Layout::FormAttachment.new(100, 0)
289
293
  end
290
-
294
+
291
295
  @sash.add_selection_listener do |e|
292
296
  sash_rect = @sash.bounds
293
297
  shell_rect = @shell.client_area
@@ -302,31 +306,31 @@ module Redcar
302
306
  @shell.layout
303
307
  end
304
308
  end
305
-
309
+
306
310
  @left_composite.layout_data = Swt::Layout::FormData.new.tap do |l|
307
311
  l.left = Swt::Layout::FormAttachment.new(0, 5)
308
312
  l.right = Swt::Layout::FormAttachment.new(@sash, 0)
309
313
  l.top = Swt::Layout::FormAttachment.new(0, 5 + TOOLBAR_HEIGHT)
310
314
  l.bottom = Swt::Layout::FormAttachment.new(100, -5)
311
315
  end
312
-
316
+
313
317
  @right_composite.layout_data = Swt::Layout::FormData.new.tap do |d|
314
318
  d.left = Swt::Layout::FormAttachment.new(@sash, 0)
315
319
  d.right = Swt::Layout::FormAttachment.new(100, -5)
316
320
  d.top = Swt::Layout::FormAttachment.new(0, 5 + TOOLBAR_HEIGHT)
317
321
  d.bottom = Swt::Layout::FormAttachment.new(100, -5)
318
322
  end
319
-
323
+
320
324
  @tree_sash = Swt::Custom::SashForm.new(@left_composite, orientation)
321
325
  grid_data = Swt::Layout::GridData.new(Swt::Layout::GridData::FILL_BOTH)
322
326
  @tree_sash.layout_data = grid_data
323
-
327
+
324
328
  @notebook_sash = Swt::Custom::SashForm.new(@right_composite, orientation)
325
329
  grid_data = Swt::Layout::GridData.new(Swt::Layout::GridData::FILL_BOTH)
326
330
  @notebook_sash.layout_data = grid_data
327
331
  @notebook_sash.sash_width = SASH_WIDTH
328
332
  end
329
-
333
+
330
334
  def horizontal_vertical(symbol)
331
335
  case symbol
332
336
  when :horizontal
@@ -335,7 +339,7 @@ module Redcar
335
339
  Swt::SWT::VERTICAL
336
340
  end
337
341
  end
338
-
342
+
339
343
  def reset_sash_widths
340
344
  @treebook_unopened = !@window.treebook.trees.any?
341
345
  width = 0
@@ -348,7 +352,7 @@ module Redcar
348
352
  end
349
353
  set_sash_widths(width)
350
354
  end
351
-
355
+
352
356
  def toggle_sash_widths
353
357
  if treebook_hidden?
354
358
  reset_sash_widths
@@ -357,18 +361,42 @@ module Redcar
357
361
  set_sash_widths(MINIMUM_TREEBOOK_WIDTH)
358
362
  end
359
363
  end
360
-
364
+
365
+ def decrease_treebook_width
366
+ width = treebook_width
367
+ unless width < MINIMUM_TREEBOOK_WIDTH + SASH_WIDTH
368
+ set_sash_widths(width-SASH_WIDTH)
369
+ end
370
+ end
371
+
372
+ def increase_treebook_width
373
+ set_sash_widths(treebook_width+SASH_WIDTH)
374
+ end
375
+
361
376
  def set_sash_widths(offset)
362
377
  @sash.layout_data.left = Swt::Layout::FormAttachment.new(0, offset)
363
378
  @shell.layout
364
379
  end
365
-
380
+
366
381
  def reset_notebook_sash_widths
367
382
  width = (100/@window.notebooks.length).to_i
368
383
  widths = [width]*@window.notebooks.length
369
384
  @notebook_sash.setWeights(widths.to_java(:int))
370
385
  end
371
-
386
+
387
+ def enlarge_notebook(index=0)
388
+ if @window.notebooks.length > 1
389
+ widths = @notebook_sash.getWeights
390
+ small = index == 0 ? 1 : 0
391
+ total = widths[index] + widths[small]
392
+ unless widths[index]/total > 0.95
393
+ widths[small] = widths[small].to_i - SASH_WIDTH
394
+ widths[index] = widths[index].to_i + SASH_WIDTH
395
+ @notebook_sash.setWeights(widths.to_a.to_java(:int))
396
+ end
397
+ end
398
+ end
399
+
372
400
  def reset_sash_height
373
401
  @sash.layout_data.top = Swt::Layout::FormAttachment.new(0, @toolbar_height.to_i)
374
402
  @left_composite.layout_data.top = Swt::Layout::FormAttachment.new(0, 5 + @toolbar_height.to_i)
@@ -376,7 +404,7 @@ module Redcar
376
404
  @shell.layout
377
405
  @shell.redraw
378
406
  end
379
-
407
+
380
408
  end
381
409
  end
382
410
  end