redcar 0.8.1 → 0.9.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 (210) hide show
  1. data/CHANGES +41 -1
  2. data/README.md +1 -1
  3. data/Rakefile +5 -6
  4. data/lib/plugin_manager/lib/plugin_manager.rb +1 -2
  5. data/lib/redcar.rb +19 -14
  6. data/lib/redcar/installer.rb +21 -17
  7. data/lib/redcar/runner.rb +10 -7
  8. data/lib/redcar/usage.rb +1 -0
  9. data/lib/redcar_quick_start.rb +8 -12
  10. data/lib/regex_replace.rb +3 -3
  11. data/plugins/application/features/step_definitions/menu_steps.rb +10 -0
  12. data/plugins/application/features/step_definitions/speedbar_steps.rb +8 -2
  13. data/plugins/application/features/step_definitions/tree_steps.rb +48 -6
  14. data/plugins/application/features/step_definitions/window_steps.rb +9 -4
  15. data/plugins/application/features/support/env.rb +20 -1
  16. data/plugins/application/features/support/fake_event.rb +14 -0
  17. data/plugins/application/lib/application.rb +29 -12
  18. data/plugins/application/lib/application/dialogs/filter_list_dialog.rb +19 -0
  19. data/plugins/application/lib/application/speedbar.rb +23 -17
  20. data/plugins/application/lib/application/tab.rb +20 -15
  21. data/plugins/application/lib/application/treebook.rb +10 -7
  22. data/plugins/application/lib/application/window.rb +1 -1
  23. data/plugins/application/plugin.rb +1 -1
  24. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +4 -4
  25. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +15 -4
  26. data/plugins/application_swt/lib/application_swt/icon.rb +3 -5
  27. data/plugins/application_swt/lib/application_swt/notebook/tab_drag_and_drop_listener.rb +4 -4
  28. data/plugins/application_swt/lib/application_swt/notebook/tab_transfer.rb +5 -5
  29. data/plugins/application_swt/lib/application_swt/speedbar.rb +34 -120
  30. data/plugins/application_swt/lib/application_swt/speedbar/button_item.rb +20 -0
  31. data/plugins/application_swt/lib/application_swt/speedbar/combo_item.rb +38 -0
  32. data/plugins/application_swt/lib/application_swt/speedbar/label_item.rb +15 -0
  33. data/plugins/application_swt/lib/application_swt/speedbar/slider_item.rb +32 -0
  34. data/plugins/application_swt/lib/application_swt/speedbar/text_box_item.rb +36 -0
  35. data/plugins/application_swt/lib/application_swt/speedbar/toggle_item.rb +29 -0
  36. data/plugins/application_swt/lib/application_swt/tab.rb +1 -3
  37. data/plugins/application_swt/lib/application_swt/toolbar.rb +19 -20
  38. data/plugins/application_swt/lib/application_swt/treebook.rb +24 -9
  39. data/plugins/application_swt/lib/application_swt/window.rb +110 -98
  40. data/plugins/application_swt/lib/swt/vtab_folder.rb +77 -32
  41. data/plugins/application_swt/lib/swt/vtab_item.rb +9 -0
  42. data/plugins/application_swt/lib/swt/vtab_label.rb +63 -23
  43. data/plugins/application_swt/plugin.rb +1 -1
  44. data/plugins/clipboard-viewer/lib/clipboard_viewer/clipboard_bar.rb +2 -2
  45. data/plugins/comment/features/line_comment.feature +116 -4
  46. data/plugins/comment/lib/comment.rb +18 -16
  47. data/plugins/connection_manager/lib/connection_manager/commands.rb +1 -1
  48. data/plugins/connection_manager/lib/connection_manager/private_key_store.rb +5 -3
  49. data/plugins/declarations/lib/declarations.rb +1 -1
  50. data/plugins/declarations/lib/declarations/parser.rb +68 -20
  51. data/plugins/document_search/features/replace.feature +18 -0
  52. data/plugins/document_search/lib/document_search.rb +37 -54
  53. data/plugins/document_search/lib/document_search/replace_all_command.rb +27 -0
  54. data/plugins/document_search/lib/document_search/replace_command.rb +38 -0
  55. data/plugins/document_search/lib/document_search/replace_next_command.rb +27 -0
  56. data/plugins/document_search/lib/document_search/search_and_replace.rb +17 -24
  57. data/plugins/edit_view/features/step_definitions/editing_steps.rb +4 -4
  58. data/plugins/edit_view/features/step_definitions/tab_steps.rb +9 -0
  59. data/plugins/edit_view/features/step_definitions/window_steps.rb +0 -12
  60. data/plugins/edit_view/lib/edit_view/document.rb +2 -0
  61. data/plugins/edit_view/lib/edit_view/document/command.rb +8 -8
  62. data/plugins/edit_view/lib/edit_view/edit_tab.rb +21 -7
  63. data/plugins/edit_view/lib/edit_view/select_font_dialog.rb +6 -0
  64. data/plugins/edit_view/lib/edit_view/select_theme_dialog.rb +6 -0
  65. data/plugins/edit_view_swt/lib/edit_view_swt.rb +92 -43
  66. data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +17 -4
  67. data/plugins/find-in-project/lib/find_in_project.rb +1 -4
  68. data/plugins/find-in-project/lib/find_in_project/commands.rb +0 -14
  69. data/plugins/find-in-project/lib/find_in_project/controllers.rb +12 -0
  70. data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +5 -0
  71. data/plugins/groovy/features/fixtures/test.groovy +0 -0
  72. data/plugins/groovy/features/step_definitions/groovy_steps.rb +27 -0
  73. data/plugins/groovy/features/support/env.rb +27 -0
  74. data/plugins/groovy/features/syntax_check_groovy.feature +72 -0
  75. data/plugins/groovy/lib/syntax_check/groovy.rb +76 -0
  76. data/plugins/groovy/plugin.rb +7 -0
  77. data/plugins/help/lib/help.rb +28 -4
  78. data/plugins/help/lib/help/help_tab.rb +11 -0
  79. data/plugins/help/lib/help/view_controller.rb +25 -0
  80. data/plugins/help/plugin.rb +2 -1
  81. data/plugins/{view_shortcuts → help}/views/default.css +0 -0
  82. data/plugins/{view_shortcuts → help}/views/index.html.erb +1 -1
  83. data/plugins/{view_shortcuts → help}/views/redcar_small_icon.png +0 -0
  84. data/plugins/html_view/features/browser_bar.feature +47 -0
  85. data/plugins/html_view/features/fixtures/other.html +1 -0
  86. data/plugins/html_view/features/fixtures/sample.html +1 -0
  87. data/plugins/html_view/features/step_definitions/html_view_steps.rb +45 -5
  88. data/plugins/html_view/features/support/env.rb +26 -0
  89. data/plugins/html_view/features/web_preview.feature +21 -0
  90. data/plugins/html_view/lib/html_controller.rb +5 -5
  91. data/plugins/html_view/lib/html_view.rb +62 -10
  92. data/plugins/{web_bookmarks/lib/web_bookmarks → html_view/lib/html_view}/browser_bar.rb +32 -20
  93. data/plugins/html_view/lib/html_view/commands.rb +64 -0
  94. data/plugins/{web_bookmarks/lib/web_bookmarks/view_controller.rb → html_view/lib/html_view/default_controller.rb} +7 -6
  95. data/plugins/html_view/lib/html_view/html_tab.rb +17 -6
  96. data/plugins/html_view/plugin.rb +3 -3
  97. data/plugins/{web_bookmarks → html_view}/views/index.html.erb +0 -0
  98. data/plugins/javascript/features/fixtures/test.js +0 -0
  99. data/plugins/javascript/features/support/env.rb +4 -0
  100. data/plugins/javascript/features/syntax_check_javascript.feature +27 -0
  101. data/plugins/javascript/lib/syntax_check/javascript.rb +52 -0
  102. data/plugins/javascript/plugin.rb +7 -0
  103. data/plugins/javascript/vendor/jslint.js +539 -0
  104. data/plugins/macros/lib/macros/commands.rb +3 -3
  105. data/plugins/open_default_app/lib/open_default_app.rb +29 -3
  106. data/plugins/open_default_app/plugin.rb +1 -1
  107. data/plugins/outline_view/features/outline_view.feature +79 -0
  108. data/plugins/outline_view/features/step_definitions/outline_steps.rb +45 -0
  109. data/plugins/outline_view/lib/outline_view.rb +1 -1
  110. data/plugins/outline_view/spec/fixtures/some_project/javascript.js +10 -0
  111. data/plugins/outline_view/spec/fixtures/some_project/nothing_to_see.rb +0 -0
  112. data/plugins/outline_view/spec/fixtures/some_project/one_lonely_class.rb +2 -0
  113. data/plugins/outline_view/spec/fixtures/some_project/similar_names.rb +18 -0
  114. data/plugins/outline_view/spec/fixtures/some_project/something_fancy.rb +736 -0
  115. data/plugins/outline_view/spec/fixtures/some_project/trailing_space.rb +5 -0
  116. data/plugins/outline_view_swt/lib/outline_view_swt.rb +17 -19
  117. data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +1 -4
  118. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +12 -3
  119. data/plugins/project/features/close_directory_tree.feature +27 -0
  120. data/plugins/project/features/highlight_focussed_tab.feature +45 -1
  121. data/plugins/project/features/open_and_save_files.feature +33 -0
  122. data/plugins/project/features/open_directory_tree.feature +37 -11
  123. data/plugins/project/features/step_definitions/directory_steps.rb +1 -1
  124. data/plugins/project/features/step_definitions/drb_steps.rb +40 -0
  125. data/plugins/project/features/support/env.rb +17 -0
  126. data/plugins/project/lib/project.rb +12 -2
  127. data/plugins/project/lib/project/commands.rb +101 -99
  128. data/plugins/project/lib/project/drb_service.rb +55 -65
  129. data/plugins/project/lib/project/manager.rb +29 -4
  130. data/plugins/project/lib/project/project_tree_controller.rb +24 -0
  131. data/plugins/project/lib/project/support/trash.rb +1 -0
  132. data/plugins/redcar/redcar.rb +100 -37
  133. data/plugins/redcar_debug/lib/redcar_debug.rb +3 -3
  134. data/plugins/repl/features/step_definitions/repl_steps.rb +3 -0
  135. data/plugins/repl/lib/repl.rb +4 -11
  136. data/plugins/repl/lib/repl/repl_tab.rb +26 -0
  137. data/plugins/ruby/features/fixtures/test.rb +0 -0
  138. data/plugins/ruby/features/support/env.rb +4 -0
  139. data/plugins/ruby/features/syntax_check_ruby.feature +25 -0
  140. data/plugins/runnables/features/command_tree.feature +28 -0
  141. data/plugins/runnables/lib/runnables.rb +1 -0
  142. data/plugins/runnables/lib/runnables/commands.rb +4 -4
  143. data/plugins/runnables/lib/runnables/output_processor.rb +5 -5
  144. data/plugins/runnables/lib/runnables/tree_mirror/tree_controller.rb +2 -7
  145. data/plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb +13 -8
  146. data/plugins/scm_git/lib/scm_git/change.rb +5 -5
  147. data/plugins/strip_trailing_spaces/features/fixtures/test.txt +3 -0
  148. data/plugins/strip_trailing_spaces/features/strip_trailing_spaces.feature +34 -0
  149. data/plugins/strip_trailing_spaces/lib/strip_trailing_spaces.rb +3 -38
  150. data/plugins/swt/lib/swt.rb +5 -13
  151. data/plugins/swt/lib/swt/full_swt.rb +15 -13
  152. data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +7 -0
  153. data/plugins/syntax_check/lib/syntax_check.rb +21 -3
  154. data/plugins/syntax_check/lib/syntax_check/error.rb +4 -3
  155. data/plugins/task_manager/lib/task_manager.rb +1 -1
  156. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Preferences/Autocompletions.tmPreferences +345 -0
  157. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Preferences/Symbol List Target.tmPreferences +22 -0
  158. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Snippets/Doc Banner.tmSnippet +20 -0
  159. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Syntaxes/Ant.tmLanguage +247 -0
  160. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/info.plist +55 -0
  161. data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/Syntaxes/GroovyRepl.plist +40 -0
  162. data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/info.plist +1 -1
  163. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Haml.tmbundle/Syntaxes/Ruby_Haml.tmLanguage +0 -1
  164. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Sass.tmbundle/Syntaxes/Ruby Sass.tmLanguage +626 -0
  165. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Sass.tmbundle/info.plist +16 -0
  166. data/plugins/todo_list/features/support/env.rb +8 -0
  167. data/plugins/todo_list/features/todo_list.feature +26 -0
  168. data/plugins/todo_list/lib/todo_list.rb +1 -0
  169. data/plugins/todo_list/lib/todo_list/file_parser.rb +23 -19
  170. data/plugins/todo_list/lib/todo_list/todo_controller.rb +60 -100
  171. data/plugins/todo_list/spec/fixtures/project/FIXME.file +3 -0
  172. data/plugins/todo_list/spec/fixtures/project/NOTE.ignored.file +1 -0
  173. data/plugins/todo_list/spec/fixtures/project/OPTIMIZE_colon.file +1 -0
  174. data/plugins/todo_list/spec/fixtures/project/XXX.ignored +1 -0
  175. data/plugins/todo_list/spec/fixtures/project/ignored_directory/TODO.file +2 -0
  176. data/plugins/todo_list/spec/fixtures/settings.rb +11 -0
  177. data/plugins/todo_list/spec/spec_helper.rb +6 -0
  178. data/plugins/todo_list/spec/todo_list/file_parser_spec.rb +35 -0
  179. data/plugins/tree/lib/tree.rb +1 -0
  180. data/plugins/tree/lib/tree/command.rb +5 -0
  181. data/plugins/web_bookmarks/features/bookmark.feature +37 -0
  182. data/plugins/web_bookmarks/features/fixtures/other.html +1 -0
  183. data/plugins/web_bookmarks/features/fixtures/sample.html +1 -0
  184. data/plugins/web_bookmarks/features/step_definitions/web_steps.rb +4 -0
  185. data/plugins/web_bookmarks/features/support/env.rb +26 -0
  186. data/plugins/web_bookmarks/lib/web_bookmarks.rb +0 -10
  187. data/plugins/web_bookmarks/lib/web_bookmarks/bookmark.rb +10 -1
  188. data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +1 -47
  189. data/plugins/web_bookmarks/lib/web_bookmarks/tree.rb +21 -14
  190. data/{plugins/application → share}/icons/close.png +0 -0
  191. data/{plugins/application → share}/icons/darwin-file.png +0 -0
  192. data/{plugins/application → share}/icons/darwin-folder.png +0 -0
  193. data/share/icons/open-source-flipped.png +0 -0
  194. data/{plugins/application/icons/redcar_icon_beta_dev.png → share/icons/redcar-icon-beta-dev.png} +0 -0
  195. data/{plugins/application/icons/redcar_icon_beta.png → share/icons/redcar-icon-beta.png} +0 -0
  196. data/{plugins/application → share}/icons/redcar-splash.png +0 -0
  197. metadata +90 -30
  198. data/lib/redcar/jvm_options_probe.rb +0 -33
  199. data/plugins/document_search/lib/document_search/replace.rb +0 -113
  200. data/plugins/document_search/lib/document_search/search.rb +0 -45
  201. data/plugins/outline_view_swt/lib/icons/alias.png +0 -0
  202. data/plugins/outline_view_swt/lib/icons/assignment.png +0 -0
  203. data/plugins/outline_view_swt/lib/icons/attribute.png +0 -0
  204. data/plugins/outline_view_swt/lib/icons/class.png +0 -0
  205. data/plugins/outline_view_swt/lib/icons/interface.png +0 -0
  206. data/plugins/outline_view_swt/lib/icons/method.png +0 -0
  207. data/plugins/strip_trailing_spaces/CHANGELOG +0 -12
  208. data/plugins/strip_trailing_spaces/README.md +0 -32
  209. data/plugins/view_shortcuts/lib/view_shortcuts.rb +0 -52
  210. data/plugins/view_shortcuts/plugin.rb +0 -11
@@ -0,0 +1,38 @@
1
+ module Redcar
2
+ class ApplicationSWT
3
+ class Speedbar
4
+ class ComboItem
5
+ def initialize(speedbar, composite, item)
6
+ combo = Swt::Widgets::Combo.new(composite, Swt::SWT::READ_ONLY)
7
+ combo.items = item.items.to_java(:string)
8
+ if item.value
9
+ combo.select(item.items.index(item.value))
10
+ end
11
+ combo.add_selection_listener do
12
+ speedbar.ignore(item.name) do
13
+ item.value = combo.text
14
+ speedbar.execute_listener_in_model(item, item.value)
15
+ end
16
+ end
17
+ item.add_listener(:changed_items) do |new_items|
18
+ speedbar.rescue_speedbar_errors do
19
+ speedbar.ignore(item.name) do
20
+ combo.items = item.items.to_java(:string)
21
+ item.value = nil
22
+ end
23
+ end
24
+ end
25
+ item.add_listener(:changed_value) do |new_value|
26
+ speedbar.rescue_speedbar_errors do
27
+ speedbar.ignore(item.name) do
28
+ combo.select(item.items.index(item.value))
29
+ end
30
+ end
31
+ end
32
+ speedbar.keyable_widgets << combo
33
+ speedbar.focussable_widgets << combo
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,15 @@
1
+ module Redcar
2
+ class ApplicationSWT
3
+ class Speedbar
4
+ class LabelItem
5
+ def initialize(speedbar, composite, item)
6
+ label = Swt::Widgets::Label.new(composite, 0)
7
+ label.set_text(item.text)
8
+ item.add_listener(:changed_text) do |new_text|
9
+ label.set_text(item.text)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,32 @@
1
+ module Redcar
2
+ class ApplicationSWT
3
+ class Speedbar
4
+ class SliderItem
5
+ def initialize(speedbar, composite, item)
6
+ slider = Swt::Widgets::Slider.new(composite, Swt::SWT::HORIZONTAL)
7
+ grid_data = Swt::Layout::GridData.new
8
+ grid_data.grabExcessHorizontalSpace = true
9
+ grid_data.horizontalAlignment = Swt::Layout::GridData::FILL
10
+ slider.layout_data = grid_data
11
+ slider.selection = item.value
12
+ slider.maximum = item.maximum || 100
13
+ slider.minimum = item.minimum || 0
14
+ slider.increment = item.increment || 5
15
+ slider.add_selection_listener do
16
+ item.value = slider.selection
17
+ speedbar.execute_listener_in_model(item, item.value)
18
+ end
19
+ [:minimum, :maximum, :increment, :enabled].each do |ivar|
20
+ item.add_listener(:"changed_#{ivar}") do |new_value|
21
+ speedbar.rescue_speedbar_errors { slider.send(:"#{ivar}=", new_value) }
22
+ end
23
+ end
24
+ item.add_listener(:changed_value) do |new_value|
25
+ speedbar.rescue_speedbar_errors { slider.selection = new_value }
26
+ end
27
+ speedbar.focussable_widgets << slider
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,36 @@
1
+ module Redcar
2
+ class ApplicationSWT
3
+ class Speedbar
4
+ class TextBoxItem
5
+ def initialize(speedbar, composite, item)
6
+ edit_view = EditView.new
7
+ item.edit_view = edit_view
8
+ edit_view_swt = EditViewSWT.new(edit_view, composite, :single_line => true)
9
+ mate_text = edit_view_swt.mate_text
10
+ mate_text.set_font(EditView.font, EditView.font_size)
11
+ mate_text.getControl.set_text(item.value)
12
+ mate_text.set_grammar_by_name "Ruby"
13
+ mate_text.set_theme_by_name(EditView.theme)
14
+ mate_text.set_root_scope_by_content_name("Ruby", "string.regexp.classic.ruby")
15
+ gridData = Swt::Layout::GridData.new
16
+ gridData.grabExcessHorizontalSpace = true
17
+ gridData.horizontalAlignment = Swt::Layout::GridData::FILL
18
+ mate_text.getControl.set_layout_data(gridData)
19
+ edit_view.document.add_listener(:changed) do
20
+ speedbar.ignore(item.name) do
21
+ item.value = edit_view.document.to_s
22
+ speedbar.execute_listener_in_model(item, item.value)
23
+ end
24
+ end
25
+ item.add_listener(:changed_value) do |new_value|
26
+ speedbar.ignore(item.name) do
27
+ mate_text.getControl.set_text(new_value)
28
+ end
29
+ end
30
+ speedbar.keyable_widgets << mate_text.getControl
31
+ speedbar.focussable_widgets << mate_text.getControl
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,29 @@
1
+ module Redcar
2
+ class ApplicationSWT
3
+ class Speedbar
4
+ class ToggleItem
5
+ def initialize(speedbar, composite, item)
6
+ button = Swt::Widgets::Button.new(composite, Swt::SWT::CHECK)
7
+ button.set_text(item.text)
8
+ button.set_selection(!!item.value)
9
+ button.add_selection_listener do
10
+ item.value = button.get_selection
11
+ speedbar.execute_listener_in_model(item, item.value)
12
+ end
13
+ item.add_listener(:changed_text) do |new_text|
14
+ speedbar.rescue_speedbar_errors do
15
+ button.set_text = new_text
16
+ end
17
+ end
18
+ item.add_listener(:changed_value) do |new_value|
19
+ speedbar.rescue_speedbar_errors do
20
+ button.set_selection(!!new_value)
21
+ end
22
+ end
23
+ speedbar.keyable_widgets << button
24
+ speedbar.focussable_widgets << button
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -4,8 +4,6 @@ module Redcar
4
4
 
5
5
  attr_reader :item, :model, :notebook, :widget
6
6
 
7
- FILE_ICON = File.join(Redcar.root, %w(plugins application lib application assets file.png))
8
-
9
7
  def initialize(model, notebook, position = nil)
10
8
  @model, @notebook = model, notebook
11
9
  create_item_widget(position || @notebook.tab_folder.item_count)
@@ -17,7 +15,7 @@ module Redcar
17
15
  position ||= notebook.tab_folder.item_count
18
16
  if @item
19
17
  @item.dispose
20
- end
18
+ end
21
19
  @item = Swt::Custom::CTabItem.new(notebook.tab_folder, Swt::SWT::CLOSE, position)
22
20
  set_icon(@model.icon)
23
21
  end
@@ -33,47 +33,46 @@ module Redcar
33
33
 
34
34
  def initialize(window, toolbar_model, options={})
35
35
  s = Time.now
36
- @toolbars = {}
37
- @coolitems = {}
36
+ @toolbars = {}
37
+ @coolitems = {}
38
38
  @entries = Hash.new{|hash, key| hash[key] = Array.new}
39
39
  @coolbar = Swt::Widgets::CoolBar.new(window.shell, Swt::SWT::FLAT | Swt::SWT::HORIZONTAL)
40
40
  return unless toolbar_model
41
- toolbar_model.each do |entry|
41
+ toolbar_model.each do |entry|
42
42
  @name = entry.barname || :new
43
43
  if not @toolbars[@name]
44
44
  if @name == :core
45
- @coolitem = Swt::Widgets::CoolItem.new(@coolbar, Swt::SWT::FLAT, 0)
46
- else
47
- @coolitem = Swt::Widgets::CoolItem.new(@coolbar, Swt::SWT::FLAT)
45
+ @coolitem = Swt::Widgets::CoolItem.new(@coolbar, Swt::SWT::FLAT, 0)
46
+ else
47
+ @coolitem = Swt::Widgets::CoolItem.new(@coolbar, Swt::SWT::FLAT)
48
48
  end
49
49
 
50
50
  @toolbars[@name] = create_toolbar(@coolbar)
51
51
  @coolitems[@name] = @coolitem
52
- else
53
- @toolbar = @toolbars[@name]
52
+ else
53
+ @toolbar = @toolbars[@name]
54
54
  @coolitem = @coolitems[@name]
55
55
  end
56
- @entries[@name] << entry
56
+ @entries[@name] << entry
57
57
  end
58
-
59
- @toolbars.each_key { |key|
60
-
58
+
59
+ @toolbars.each_key do |key|
60
+
61
61
  @toolbar = @toolbars[key]
62
- @coolitem = @coolitems[key]
63
- @toolbar_data = @entries[key]
64
- @coolitem.setControl(@toolbar)
65
-
62
+ @coolitem = @coolitems[key]
63
+ @toolbar_data = @entries[key]
64
+ @coolitem.setControl(@toolbar)
65
+
66
66
  add_entries_to_toolbar(@toolbar, @toolbar_data)
67
67
  @p = @toolbar.computeSize(Swt::SWT::DEFAULT, Swt::SWT::DEFAULT)
68
68
  @point = @coolitem.computeSize(@p.x, @p.y)
69
69
  #@coolitem.setPreferredSize(@point)
70
70
  #@coolitem.setMinimumSize(@point)
71
71
  @coolitem.setSize(@point.x, @point.y)
72
- }
73
-
72
+ end
73
+
74
74
  #puts "ApplicationSWT::ToolBar initialize took #{Time.now - s}s"
75
-
76
- @coolbar.setLocked(true)
75
+ @coolbar.setLocked(true)
77
76
  @coolbar.pack()
78
77
  end
79
78
 
@@ -23,7 +23,7 @@ module Redcar
23
23
  i.text = tree.tree_mirror.title
24
24
  i.control = TreeViewSWT.new(@tab_folder, tree)
25
25
  tree.controller = i.control
26
- @tab_folder.silent_selection(i)
26
+ @tab_folder.selection = i
27
27
  end
28
28
 
29
29
  def tree_removed(tree)
@@ -33,25 +33,40 @@ module Redcar
33
33
 
34
34
  def tree_focussed(tree)
35
35
  item = @tab_folder.get_item(tree.tree_mirror.title)
36
- @tab_folder.silent_selection(item)
36
+ @tab_folder.selection = item
37
37
  end
38
38
 
39
39
  def create_tree_view
40
40
  @tab_folder = Swt::Widgets::VTabFolder.new(@window.tree_sash, Swt::SWT::NONE)
41
- colors = [ Swt::Graphics::Color.new(display, 230, 240, 255),
42
- Swt::Graphics::Color.new(display, 170, 199, 246),
43
- Swt::Graphics::Color.new(display, 135, 178, 247) ]
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
+ ]
44
46
  percents = [60, 85]
45
47
  @tab_folder.set_selection_background(colors, percents, true)
46
48
 
47
- @tab_folder.add_selection_listener do |event|
49
+ attach_view_listeners
50
+
51
+ @tab_folder.layout
52
+ @window.left_composite.layout
53
+ end
54
+
55
+ def attach_view_listeners
56
+ @tab_folder.add_ctab_folder2_listener do |event|
57
+ # Close event
48
58
  tab_item = event.item
49
59
  tree_view_swt = tab_item.control
50
- @model.focus_tree(tree_view_swt.model)
60
+ @model.remove_tree(tree_view_swt.model)
51
61
  end
52
62
 
53
- @tab_folder.layout
54
- @window.left_composite.layout
63
+ @tab_folder.add_selection_listener do |event|
64
+ # Widget selected event
65
+ tab_item = event.item
66
+ tree_view_swt = tab_item.control
67
+ tree = tree_view_swt.model
68
+ @model.focus_tree(tree)
69
+ end
55
70
  end
56
71
  end
57
72
  end
@@ -3,41 +3,43 @@ module Redcar
3
3
  class ApplicationSWT
4
4
  class Window
5
5
  attr_reader :shell, :window
6
-
7
- SASH_WIDTH = 5
8
- TREEBOOK_WIDTH = 200
9
- TOOLBAR_HEIGHT = 25
10
- @toolbar_height = 30
11
-
6
+
7
+ SASH_WIDTH = 5
8
+ TREEBOOK_WIDTH = 200
9
+ MINIMUM_TREEBOOK_WIDTH = 0
10
+ VISIBLE_TREEBOOK_WIDTH = 25
11
+ TOOLBAR_HEIGHT = 25
12
+ @toolbar_height = 30
13
+
12
14
  class ShellListener
13
15
  include org.eclipse.swt.events.ShellListener
14
-
16
+
15
17
  def initialize(controller)
16
18
  @win = controller.window
17
19
  end
18
-
20
+
19
21
  def shell_closed(e)
20
22
  unless Redcar.app.events.ignore?(:window_close, @win)
21
23
  e.doit = false
22
24
  Redcar.app.events.create(:window_close, @win)
23
25
  end
24
26
  end
25
-
27
+
26
28
  def shell_activated(e)
27
29
  unless Redcar.app.events.ignore?(:window_focus, @win)
28
30
  e.doit = false
29
31
  Redcar.app.events.create(:window_focus, @win)
30
32
  end
31
33
  end
32
-
34
+
33
35
  def shell_deactivated(_); end
34
36
  def shell_deiconified(_); end
35
37
  def shell_iconified(_); end
36
38
  end
37
-
39
+
38
40
  def initialize(window)
39
41
  @window = window
40
- @notebook_handlers = Hash.new {|h,k| h[k] = []}
42
+ @notebook_handlers = Hash.new {|h,k| h[k] = []}
41
43
  create_shell
42
44
  create_sashes(window)
43
45
  new_notebook(window.notebooks.first)
@@ -47,7 +49,7 @@ module Redcar
47
49
  @treebook_unopened = true
48
50
  set_icon
49
51
  end
50
-
52
+
51
53
  def add_listeners
52
54
  @window.add_listener(:show, &method(:show))
53
55
  @window.add_listener(:refresh_menu, &method(:refresh_menu))
@@ -63,110 +65,117 @@ module Redcar
63
65
  @window.add_listener(:focussed, &method(:focussed))
64
66
  @window.add_listener(:speedbar_opened, &method(:speedbar_opened))
65
67
  @window.add_listener(:speedbar_closed, &method(:speedbar_closed))
66
-
68
+
67
69
  @window.add_listener(:toggle_trees_visible, &method(:toggle_sash_widths))
68
-
69
70
  @window.treebook.add_listener(:tree_added) do
70
71
  if @treebook_unopened or not @window.trees_visible?
71
72
  reset_sash_widths
72
73
  @treebook_unopened = false
73
74
  end
74
75
  end
75
-
76
+ @window.treebook.add_listener(:tree_focussed) do |tree|
77
+ if @treebook_unopened or not @window.trees_visible?
78
+ reset_sash_widths
79
+ @treebook_unopened = false
80
+ end
81
+ end
82
+
76
83
  @window.treebook.add_listener(:tree_removed) do
77
84
  reset_sash_widths
78
85
  end
79
86
  @shell.add_key_listener(KeyListener.new(self))
80
87
  end
81
-
82
- def treebook_visible?
83
- @sash.layout_data.left.offset > SASH_WIDTH
88
+
89
+ def treebook_hidden?
90
+ treebook_width <= VISIBLE_TREEBOOK_WIDTH
84
91
  end
85
-
92
+
93
+ def treebook_width
94
+ @sash.layout_data.left.offset
95
+ end
96
+
97
+ def default_treebook_width
98
+ TREEBOOK_WIDTH + SASH_WIDTH
99
+ end
100
+
86
101
  def fullscreen
87
102
  @shell.fullScreen()
88
103
  end
89
-
104
+
90
105
  def fullscreen=(value)
91
106
  @shell.setFullScreen(value)
92
107
  end
93
-
108
+
94
109
  class KeyListener
95
110
  def initialize(edit_view_swt)
96
111
  @edit_view_swt = edit_view_swt
97
112
  end
98
-
113
+
99
114
  def key_pressed(key_event)
100
- p key_event
115
+ p key_event
101
116
  if key_event.character == Swt::SWT::TAB
102
- p :tab_pressedwin
117
+ p :tab_pressedwin
103
118
  elsif key_event.character == Swt::SWT::ESC
104
- p :esc_pressedwin
119
+ p :esc_pressedwin
105
120
  end
106
121
  end
107
-
122
+
108
123
  def verify_key(key_event)
109
- p :verkey
124
+ p :verkey
110
125
  if key_event.character == Swt::SWT::TAB
111
- p :tab_pressed
112
- key_event.doit = false
126
+ p :tab_pressed
127
+ key_event.doit = false
113
128
  end
114
129
  end
115
-
130
+
116
131
  def key_released(key_event)
117
132
  end
118
133
  end
119
-
134
+
120
135
  def create_treebook_controller
121
136
  treebook = @window.treebook
122
137
  controller = ApplicationSWT::Treebook.new(
123
- self,
124
- treebook)
138
+ self,
139
+ treebook)
125
140
  treebook.controller = controller
126
141
  end
127
-
142
+
128
143
  def show
129
144
  @shell.open
130
145
  @shell.text = window.title
131
146
  end
132
-
147
+
133
148
  def refresh_menu
134
149
  old_menu_bar = shell.menu_bar
135
150
  @menu_controller = ApplicationSWT::Menu.new(self, Redcar.app.main_menu(@window), Redcar.app.main_keymap, Swt::SWT::BAR)
136
151
  shell.menu_bar = @menu_controller.menu_bar
137
152
  old_menu_bar.dispose if old_menu_bar
138
153
  end
139
-
154
+
140
155
  def refresh_toolbar
141
- if Redcar.app.show_toolbar?
142
- @toolbar_controller = ApplicationSWT::ToolBar.new(self, Redcar.app.main_toolbar, Swt::SWT::HORIZONTAL | Swt::SWT::BORDER)
143
- @toolbar_controller.show()
144
- @toolbar_height = @toolbar_controller.height.to_i
145
- else
146
- @toolbar_controller.hide() if @toolbar_controller
147
- @toolbar_height = 0
148
- end
149
- reset_sash_height
156
+ if Redcar.app.show_toolbar?
157
+ @toolbar_controller = ApplicationSWT::ToolBar.new(self, Redcar.app.main_toolbar, Swt::SWT::HORIZONTAL | Swt::SWT::BORDER)
158
+ @toolbar_controller.show()
159
+ @toolbar_height = @toolbar_controller.height.to_i
160
+ else
161
+ @toolbar_controller.hide() if @toolbar_controller
162
+ @toolbar_height = 0
163
+ end
164
+ reset_sash_height
150
165
  end
151
-
166
+
152
167
  def set_icon
153
- path = File.join(icon_dir, icon_file)
154
- icon = Swt::Graphics::Image.new(ApplicationSWT.display, path)
155
- shell.image = icon
168
+ shell.image = Icon.swt_image(icon_file)
156
169
  end
157
-
158
- def icon_dir
159
- File.join(Redcar.root, %w(plugins application icons))
160
- end
161
-
170
+
162
171
  def icon_file
163
172
  if Redcar::VERSION =~ /dev$/
164
- "redcar_icon_beta_dev.png"
173
+ :redcar_icon_beta_dev
165
174
  else
166
- "redcar_icon_beta.png"
175
+ :redcar_icon_beta
167
176
  end
168
177
  end
169
-
178
+
170
179
  def bring_to_front
171
180
  @shell.set_minimized(false) # unminimize, just in case
172
181
  @shell.redraw
@@ -177,34 +186,34 @@ module Redcar
177
186
  @shell.force_active # doesn't do anything, really
178
187
  @shell.set_active
179
188
  end
180
-
189
+
181
190
  def popup_menu(menu)
182
191
  menu.controller = ApplicationSWT::Menu.new(self, menu, nil, Swt::SWT::POP_UP)
183
192
  menu.controller.show
184
193
  end
185
-
194
+
186
195
  def popup_menu_with_numbers(menu)
187
196
  menu.controller = ApplicationSWT::Menu.new(self, menu, nil, Swt::SWT::POP_UP, :numbers => true)
188
197
  menu.controller.show
189
198
  end
190
-
199
+
191
200
  def speedbar_opened(speedbar)
192
201
  speedbar.controller = ApplicationSWT::Speedbar.new(@window, right_composite, speedbar)
193
202
  end
194
-
203
+
195
204
  def speedbar_closed(speedbar)
196
205
  speedbar.controller.close
197
206
  end
198
-
207
+
199
208
  def title_changed(new_title)
200
209
  @shell.text = new_title
201
210
  end
202
-
211
+
203
212
  def new_notebook(notebook_model)
204
213
  notebook_controller = ApplicationSWT::Notebook.new(notebook_model, @notebook_sash)
205
214
  reset_notebook_sash_widths
206
215
  end
207
-
216
+
208
217
  def notebook_removed(notebook_model)
209
218
  notebook_controller = notebook_model.controller
210
219
  @notebook_handlers[notebook_model].each do |h|
@@ -213,32 +222,32 @@ module Redcar
213
222
  notebook_controller.dispose
214
223
  reset_notebook_sash_widths
215
224
  end
216
-
225
+
217
226
  def notebook_orientation_changed(new_orientation)
218
227
  orientation = horizontal_vertical(new_orientation)
219
228
  @notebook_sash.setOrientation(orientation)
220
229
  end
221
-
230
+
222
231
  def focussed(_)
223
232
  @shell.set_active
224
233
  end
225
-
234
+
226
235
  def closed(_)
227
236
  @shell.close
228
237
  @menu_controller.close
229
238
  @toolbar_controller.close if @toolbar_controller
230
239
  end
231
-
240
+
232
241
  def dispose
233
242
  @shell.dispose
234
243
  @menu_controller.close
235
244
  @toolbar_controller.close
236
245
  end
237
-
246
+
238
247
  attr_reader :right_composite, :left_composite, :tree_composite, :tree_layout, :tree_sash
239
-
248
+
240
249
  private
241
-
250
+
242
251
  def create_shell
243
252
  @shell = Swt::Widgets::Shell.new(ApplicationSWT.display)
244
253
  @shell.layout = Swt::Layout::FormLayout.new
@@ -251,10 +260,10 @@ module Redcar
251
260
  end
252
261
  ApplicationSWT.register_shell(@shell)
253
262
  end
254
-
263
+
255
264
  def create_sashes(window_model)
256
265
  orientation = horizontal_vertical(window_model.notebook_orientation)
257
-
266
+
258
267
  @left_composite = Swt::Widgets::Composite.new(@shell, Swt::SWT::NONE)
259
268
  @left_composite.layout = Swt::Layout::GridLayout.new(1, false).tap do |l|
260
269
  l.verticalSpacing = 0
@@ -262,9 +271,9 @@ module Redcar
262
271
  l.horizontalSpacing = 0
263
272
  l.marginWidth = 0
264
273
  end
265
-
274
+
266
275
  @sash = Swt::Widgets::Sash.new(@shell, Swt::SWT::VERTICAL)
267
-
276
+
268
277
  @right_composite = Swt::Widgets::Composite.new(@shell, Swt::SWT::NONE)
269
278
  @right_composite.layout = Swt::Layout::GridLayout.new(1, false).tap do |l|
270
279
  l.verticalSpacing = 0
@@ -272,13 +281,13 @@ module Redcar
272
281
  l.horizontalSpacing = 0
273
282
  l.marginWidth = 0
274
283
  end
275
-
284
+
276
285
  @sash.layout_data = Swt::Layout::FormData.new.tap do |d|
277
286
  d.left = Swt::Layout::FormAttachment.new(0, 0)
278
287
  d.top = Swt::Layout::FormAttachment.new(0, 5 + TOOLBAR_HEIGHT)
279
288
  d.bottom = Swt::Layout::FormAttachment.new(100, 0)
280
289
  end
281
-
290
+
282
291
  @sash.add_selection_listener do |e|
283
292
  sash_rect = @sash.bounds
284
293
  shell_rect = @shell.client_area
@@ -293,31 +302,31 @@ module Redcar
293
302
  @shell.layout
294
303
  end
295
304
  end
296
-
305
+
297
306
  @left_composite.layout_data = Swt::Layout::FormData.new.tap do |l|
298
307
  l.left = Swt::Layout::FormAttachment.new(0, 5)
299
308
  l.right = Swt::Layout::FormAttachment.new(@sash, 0)
300
309
  l.top = Swt::Layout::FormAttachment.new(0, 5 + TOOLBAR_HEIGHT)
301
310
  l.bottom = Swt::Layout::FormAttachment.new(100, -5)
302
311
  end
303
-
312
+
304
313
  @right_composite.layout_data = Swt::Layout::FormData.new.tap do |d|
305
314
  d.left = Swt::Layout::FormAttachment.new(@sash, 0)
306
315
  d.right = Swt::Layout::FormAttachment.new(100, -5)
307
316
  d.top = Swt::Layout::FormAttachment.new(0, 5 + TOOLBAR_HEIGHT)
308
317
  d.bottom = Swt::Layout::FormAttachment.new(100, -5)
309
318
  end
310
-
319
+
311
320
  @tree_sash = Swt::Custom::SashForm.new(@left_composite, orientation)
312
321
  grid_data = Swt::Layout::GridData.new(Swt::Layout::GridData::FILL_BOTH)
313
322
  @tree_sash.layout_data = grid_data
314
-
323
+
315
324
  @notebook_sash = Swt::Custom::SashForm.new(@right_composite, orientation)
316
325
  grid_data = Swt::Layout::GridData.new(Swt::Layout::GridData::FILL_BOTH)
317
326
  @notebook_sash.layout_data = grid_data
318
327
  @notebook_sash.sash_width = SASH_WIDTH
319
328
  end
320
-
329
+
321
330
  def horizontal_vertical(symbol)
322
331
  case symbol
323
332
  when :horizontal
@@ -326,45 +335,48 @@ module Redcar
326
335
  Swt::SWT::VERTICAL
327
336
  end
328
337
  end
329
-
338
+
330
339
  def reset_sash_widths
331
340
  @treebook_unopened = !@window.treebook.trees.any?
341
+ width = 0
332
342
  if @window.treebook.trees.any?
333
- @sash.layout_data.left = Swt::Layout::FormAttachment.new(0, TREEBOOK_WIDTH + SASH_WIDTH)
334
- else
335
- @sash.layout_data.left = Swt::Layout::FormAttachment.new(0, 0)
343
+ if @treebook_open_width
344
+ width = @treebook_open_width
345
+ else
346
+ width = default_treebook_width
347
+ end
336
348
  end
337
- @shell.layout
349
+ set_sash_widths(width)
338
350
  end
339
-
351
+
340
352
  def toggle_sash_widths
341
- if not treebook_visible?
353
+ if treebook_hidden?
342
354
  reset_sash_widths
343
355
  else
344
- @sash.layout_data.left = Swt::Layout::FormAttachment.new(0, 0)
345
- @shell.layout
356
+ @treebook_open_width = treebook_width
357
+ set_sash_widths(MINIMUM_TREEBOOK_WIDTH)
346
358
  end
347
359
  end
348
-
360
+
349
361
  def set_sash_widths(offset)
350
362
  @sash.layout_data.left = Swt::Layout::FormAttachment.new(0, offset)
351
363
  @shell.layout
352
364
  end
353
-
365
+
354
366
  def reset_notebook_sash_widths
355
367
  width = (100/@window.notebooks.length).to_i
356
368
  widths = [width]*@window.notebooks.length
357
- @notebook_sash.setWeights(widths.to_java(:int))
369
+ @notebook_sash.setWeights(widths.to_java(:int))
358
370
  end
359
-
371
+
360
372
  def reset_sash_height
361
373
  @sash.layout_data.top = Swt::Layout::FormAttachment.new(0, @toolbar_height.to_i)
362
374
  @left_composite.layout_data.top = Swt::Layout::FormAttachment.new(0, 5 + @toolbar_height.to_i)
363
375
  @right_composite.layout_data.top = Swt::Layout::FormAttachment.new(0, 5 + @toolbar_height.to_i)
364
- @shell.layout
376
+ @shell.layout
365
377
  @shell.redraw
366
378
  end
367
-
379
+
368
380
  end
369
381
  end
370
382
  end