redcar 0.3.4.3 → 0.3.5

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 (196) hide show
  1. data/CHANGES +45 -0
  2. data/README.md +2 -1
  3. data/ROADMAP.md +0 -1
  4. data/Rakefile +10 -4
  5. data/bin/redcar +2 -2
  6. data/lib/openssl/build.properties +7 -0
  7. data/lib/plugin_manager/lib/plugin_manager.rb +10 -0
  8. data/lib/plugin_manager/lib/plugin_manager/plugin_definition.rb +1 -13
  9. data/lib/redcar.rb +12 -8
  10. data/lib/redcar/installer.rb +16 -15
  11. data/lib/redcar/ruby_extensions.rb +146 -1
  12. data/lib/redcar/runner.rb +16 -7
  13. data/lib/redcar/usage.rb +4 -7
  14. data/lib/redcar_quick_start.rb +5 -5
  15. data/lib/regex_replace.rb +0 -7
  16. data/plugins/application/features/step_definitions/command_steps.rb +5 -0
  17. data/plugins/application/features/step_definitions/dialog_steps.rb +5 -0
  18. data/plugins/application/features/step_definitions/filter_list_dialog_steps.rb +38 -0
  19. data/plugins/application/features/step_definitions/window_steps.rb +1 -1
  20. data/plugins/application/features/support/env.rb +44 -8
  21. data/plugins/application/lib/application.rb +32 -33
  22. data/plugins/application/lib/application/command.rb +32 -2
  23. data/plugins/application/lib/application/command/executor.rb +2 -12
  24. data/plugins/application/lib/application/dialog.rb +14 -14
  25. data/plugins/application/lib/application/event_spewer.rb +32 -0
  26. data/plugins/application/lib/application/menu.rb +5 -5
  27. data/plugins/application/lib/application/menu/builder.rb +5 -0
  28. data/plugins/application/lib/application/menu/lazy_menu.rb +24 -0
  29. data/plugins/application/lib/application/notebook.rb +4 -3
  30. data/plugins/application/lib/application/tab.rb +6 -2
  31. data/plugins/application/lib/application/window.rb +8 -4
  32. data/plugins/application/spec/application/menu/builder_spec.rb +17 -1
  33. data/plugins/application/spec/application/notebook_spec.rb +1 -1
  34. data/plugins/application_swt/build.xml +74 -0
  35. data/plugins/application_swt/lib/application_swt.rb +79 -0
  36. data/plugins/application_swt/lib/application_swt/cucumber_patches.rb +6 -1
  37. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +25 -17
  38. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +50 -12
  39. data/plugins/application_swt/lib/application_swt/html_tab.rb +20 -0
  40. data/plugins/application_swt/lib/application_swt/menu.rb +26 -2
  41. data/plugins/application_swt/lib/application_swt/notebook.rb +10 -12
  42. data/plugins/application_swt/lib/application_swt/window.rb +11 -11
  43. data/plugins/application_swt/src/com/redcareditor/application_swt/CocoaUIEnhancer.java +313 -0
  44. data/plugins/auto_completer/lib/auto_completer.rb +74 -67
  45. data/plugins/auto_completer/lib/auto_completer/current_document_completion_source.rb +19 -0
  46. data/plugins/auto_completer/lib/auto_completer/document_controller.rb +2 -2
  47. data/plugins/auto_completer/lib/auto_completer/word_list.rb +8 -1
  48. data/plugins/auto_indenter/features/ruby_style_indentation.feature +24 -0
  49. data/plugins/auto_indenter/features/step_definitions/indentation_steps.rb +6 -0
  50. data/plugins/auto_indenter/features/support/env.rb +2 -0
  51. data/plugins/auto_indenter/lib/auto_indenter.rb +86 -0
  52. data/plugins/auto_indenter/lib/auto_indenter/analyzer.rb +91 -0
  53. data/plugins/auto_indenter/lib/auto_indenter/commands.rb +34 -0
  54. data/plugins/auto_indenter/lib/auto_indenter/document_controller.rb +67 -12
  55. data/plugins/auto_indenter/lib/auto_indenter/rules.rb +41 -0
  56. data/plugins/auto_indenter/spec/auto_indenter/analyzer_spec.rb +151 -0
  57. data/plugins/auto_indenter/spec/spec_helper.rb +5 -0
  58. data/plugins/auto_pairer/lib/auto_pairer.rb +1 -0
  59. data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +43 -42
  60. data/plugins/auto_pairer/lib/auto_pairer/pairs_for_scope.rb +1 -5
  61. data/plugins/core/lib/core.rb +12 -1
  62. data/plugins/core/lib/core/observable.rb +7 -7
  63. data/plugins/core/lib/core/persistent_cache.rb +14 -2
  64. data/plugins/core/lib/core/plugin.rb +7 -0
  65. data/plugins/core/lib/core/resource.rb +78 -0
  66. data/plugins/core/lib/core/task.rb +62 -0
  67. data/plugins/core/lib/core/task_queue.rb +72 -0
  68. data/plugins/core/spec/core/resource_spec.rb +124 -0
  69. data/plugins/core/spec/core/task_queue_spec.rb +202 -0
  70. data/plugins/core/spec/spec_helper.rb +23 -1
  71. data/plugins/declarations/TODO +3 -0
  72. data/plugins/declarations/lib/declarations.rb +144 -0
  73. data/plugins/declarations/lib/declarations/completion_source.rb +22 -0
  74. data/plugins/declarations/lib/declarations/file.rb +68 -0
  75. data/plugins/declarations/lib/declarations/parser.rb +94 -0
  76. data/plugins/declarations/lib/declarations/select_tag_dialog.rb +44 -0
  77. data/plugins/declarations/plugin.rb +7 -0
  78. data/plugins/declarations/spec/declarations/file_spec.rb +62 -0
  79. data/plugins/declarations/spec/fixtures/federalist.rb +15 -0
  80. data/plugins/declarations/spec/spec_helper.rb +4 -0
  81. data/plugins/edit_view/features/indentation_commands.feature +40 -0
  82. data/plugins/edit_view/features/line_delimiter.feature +40 -0
  83. data/plugins/edit_view/features/step_definitions/editing_steps.rb +16 -4
  84. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +1 -1
  85. data/plugins/edit_view/features/step_definitions/tab_steps.rb +1 -1
  86. data/plugins/edit_view/features/step_definitions/window_steps.rb +5 -1
  87. data/plugins/edit_view/features/support/env.rb +3 -5
  88. data/plugins/edit_view/features/undo_and_redo.feature +21 -0
  89. data/plugins/edit_view/lib/edit_view.rb +57 -4
  90. data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +19 -3
  91. data/plugins/edit_view/lib/edit_view/document.rb +46 -11
  92. data/plugins/edit_view/lib/edit_view/document/indentation.rb +35 -0
  93. data/plugins/edit_view/lib/edit_view/modified_tabs_checker.rb +35 -0
  94. data/plugins/edit_view/lib/edit_view/tab_settings.rb +13 -3
  95. data/plugins/edit_view/spec/edit_view/document/indentation_spec.rb +112 -0
  96. data/plugins/edit_view/spec/edit_view/document_spec.rb +22 -0
  97. data/plugins/edit_view/spec/spec_helper.rb +1 -0
  98. data/plugins/edit_view_swt/lib/edit_view_swt.rb +59 -7
  99. data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +3 -3
  100. data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +2 -2
  101. data/plugins/edit_view_swt/vendor/java-mateview.rb +3 -2
  102. data/plugins/encryption/encryption.rb +13 -6
  103. data/plugins/execute_current_tab/lib/execute_current_tab.rb +25 -15
  104. data/plugins/html_view/assets/redcar.css +32 -1
  105. data/plugins/html_view/lib/html_view.rb +23 -3
  106. data/plugins/html_view/lib/html_view/html_tab.rb +4 -0
  107. data/plugins/my_plugin/lib/my_plugin.rb +4 -12
  108. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +1 -0
  109. data/plugins/plugin_manager_ui/views/index.html.erb +30 -37
  110. data/plugins/project/features/find_file.feature +75 -0
  111. data/plugins/project/features/open_and_save_files.feature +7 -7
  112. data/plugins/project/features/open_directory_tree.feature +11 -3
  113. data/plugins/project/features/refresh_directory_tree.feature +7 -1
  114. data/plugins/project/features/step_definitions/directory_steps.rb +11 -1
  115. data/plugins/project/features/step_definitions/file_steps.rb +10 -0
  116. data/plugins/project/features/support/env.rb +6 -1
  117. data/plugins/project/features/watch_for_modified_files.feature +79 -0
  118. data/plugins/project/lib/project.rb +72 -306
  119. data/plugins/project/lib/project/commands.rb +128 -0
  120. data/plugins/project/lib/project/dir_mirror.rb +5 -1
  121. data/plugins/project/lib/project/drb_service.rb +21 -31
  122. data/plugins/project/lib/project/file_list.rb +76 -0
  123. data/plugins/project/lib/project/file_mirror.rb +13 -1
  124. data/plugins/project/lib/project/find_file_dialog.rb +22 -52
  125. data/plugins/project/lib/project/manager.rb +210 -0
  126. data/plugins/project/lib/project/recent_directories.rb +16 -3
  127. data/plugins/project/plugin.rb +1 -1
  128. data/plugins/project/spec/fixtures/myproject/README +2 -0
  129. data/plugins/project/spec/fixtures/myproject/lib/foo_lib.rb +1 -0
  130. data/plugins/project/spec/fixtures/myproject/spec/foo_spec.rb +1 -0
  131. data/plugins/project/{features → spec}/fixtures/winter.txt +0 -0
  132. data/plugins/project/spec/project/dir_mirror_spec.rb +1 -12
  133. data/plugins/project/spec/project/file_list_spec.rb +140 -0
  134. data/plugins/project/spec/spec_helper.rb +20 -0
  135. data/plugins/redcar/plugin.rb +1 -0
  136. data/plugins/redcar/redcar.rb +254 -84
  137. data/plugins/redcar_debug/lib/redcar_debug.rb +58 -11
  138. data/plugins/redcar_debug/vendor/jruby-prof/README +46 -0
  139. data/plugins/redcar_debug/vendor/jruby-prof/Rakefile +36 -0
  140. data/plugins/redcar_debug/vendor/jruby-prof/build.xml +31 -0
  141. data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.html +22677 -0
  142. data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.txt +589 -0
  143. data/plugins/redcar_debug/vendor/jruby-prof/example/flat.txt +28 -0
  144. data/plugins/redcar_debug/vendor/jruby-prof/example/graph.html +1670 -0
  145. data/plugins/redcar_debug/vendor/jruby-prof/example/graph.txt +125 -0
  146. data/plugins/redcar_debug/vendor/jruby-prof/example/pidigits.rb +92 -0
  147. data/plugins/redcar_debug/vendor/jruby-prof/example/test.rb +28 -0
  148. data/plugins/redcar_debug/vendor/jruby-prof/example/test2.rb +29 -0
  149. data/plugins/redcar_debug/vendor/jruby-prof/example/test_exception.rb +28 -0
  150. data/plugins/redcar_debug/vendor/jruby-prof/example/test_overhead.rb +43 -0
  151. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof.rb +66 -0
  152. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/abstract_printer.rb +21 -0
  153. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/flat_text_printer.rb +35 -0
  154. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_html_printer.rb +123 -0
  155. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_text_printer.rb +45 -0
  156. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/invocation_set.rb +34 -0
  157. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/method.rb +107 -0
  158. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/profile_invocation.rb +43 -0
  159. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/simple_tree_printer.rb +27 -0
  160. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/tree_html_printer.rb +144 -0
  161. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/Invocation.java +14 -0
  162. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/JRubyProf.java +94 -0
  163. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/ProfEventHook.java +49 -0
  164. data/plugins/redcar_debug/vendor/jruby-prof/templates/graph_row.html.erb +18 -0
  165. data/plugins/redcar_debug/vendor/jruby-prof/test/basic_test.rb +291 -0
  166. data/plugins/redcar_debug/views/history.html.erb +33 -0
  167. data/plugins/redcar_debug/views/index.html.erb +33 -0
  168. data/plugins/repl/lib/repl/internal_mirror.rb +3 -15
  169. data/plugins/repl/spec/repl/internal_mirror_spec.rb +2 -2
  170. data/plugins/snippets/lib/snippets.rb +0 -1
  171. data/plugins/snippets/lib/snippets/document_controller.rb +7 -1
  172. data/plugins/task_manager/lib/task_manager.rb +28 -0
  173. data/plugins/task_manager/plugin.rb +11 -0
  174. data/plugins/task_manager/views/index.html.erb +67 -0
  175. data/plugins/textmate/lib/textmate.rb +17 -21
  176. data/plugins/textmate/lib/textmate/plist.rb +1 -2
  177. data/plugins/textmate/lib/textmate/preference.rb +5 -1
  178. data/plugins/textmate/lib/textmate/snippet.rb +6 -1
  179. data/plugins/tree_view_swt/lib/tree_view_swt.rb +0 -6
  180. data/textmate/Bundles/Cucumber.tmbundle/Preferences/Comments.tmPreferences +1 -1
  181. data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Cucumber_Plain_Text_Feature_Completions.tmPreferences +30 -0
  182. data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Symbol_list___Scenario.tmPreferences +19 -0
  183. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Plain_Text_Feature.tmLanguage +221 -0
  184. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Steps.tmLanguage +424 -0
  185. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/plaintext_template.erb +19 -77
  186. data/textmate/Bundles/Cucumber.tmbundle/info.plist +1 -20
  187. data/textmate/Bundles/Perl.tmbundle/Syntaxes/Perl.plist +1 -1
  188. data/textmate/Themes/Emacs Strict.tmTheme +241 -0
  189. data/textmate/Themes/IR_White.tmTheme +792 -0
  190. data/textmate/Themes/Monokai.tmTheme +291 -0
  191. data/textmate/Themes/WhysPoignant.tmTheme +191 -0
  192. metadata +92 -7
  193. data/plugins/application/features/main_window.feature +0 -8
  194. data/plugins/project/lib/project/project_command.rb +0 -5
  195. data/textmate/Bundles/Cucumber.tmbundle/Snippets/Scenario.tmSnippet +0 -22
  196. data/textmate/Bundles/Cucumber.tmbundle/Snippets/Story.tmSnippet +0 -25
@@ -5,8 +5,8 @@ module Redcar
5
5
  include Redcar::Core::HasLogger
6
6
 
7
7
  def self.current_environment
8
- win = Redcar.app.focussed_window
9
- tab = Redcar.app.focussed_window.focussed_notebook.focussed_tab
8
+ win = Redcar.app.focussed_window
9
+ tab = Redcar.app.focussed_notebook_tab
10
10
  { :win => win,
11
11
  :tab => tab }
12
12
  end
@@ -22,10 +22,8 @@ module Redcar
22
22
  result = @command_instance.execute
23
23
  rescue Object => e
24
24
  @command_instance.error = e
25
- log_error
26
25
  rescue java.lang.StackOverflowError => e
27
26
  @command_instance.error = e
28
- log_error
29
27
  end
30
28
  record
31
29
  result
@@ -33,14 +31,6 @@ module Redcar
33
31
 
34
32
  private
35
33
 
36
- def log_error
37
- logger.error "* Error in command #{@command_instance.class}"
38
- if @command_instance.error.respond_to?(:backtrace)
39
- logger.error " " + @command_instance.error.message.to_s
40
- @command_instance.error.backtrace.each {|l| logger.error(" " + l) }
41
- end
42
- end
43
-
44
34
  def record
45
35
  if Redcar.app.history
46
36
  Redcar.app.history.record(@command_instance)
@@ -2,18 +2,18 @@ module Redcar
2
2
  class Application
3
3
  class Dialog
4
4
  # Prompt the user with an open file dialog. Returns a path.
5
- def self.open_file(window, options)
6
- Redcar.gui.dialog_adapter.open_file(window, options)
5
+ def self.open_file(options)
6
+ Redcar.gui.dialog_adapter.open_file(options)
7
7
  end
8
8
 
9
9
  # Prompt the user with an open directory dialog. Returns a path.
10
- def self.open_directory(window, options)
11
- Redcar.gui.dialog_adapter.open_directory(window, options)
10
+ def self.open_directory(options)
11
+ Redcar.gui.dialog_adapter.open_directory(options)
12
12
  end
13
13
 
14
14
  # Prompt the user with an save file dialog. Returns a path.
15
- def self.save_file(window, options)
16
- Redcar.gui.dialog_adapter.save_file(window, options)
15
+ def self.save_file(options)
16
+ Redcar.gui.dialog_adapter.save_file(options)
17
17
  end
18
18
 
19
19
  # Show a message to the user. Requires a message and
@@ -26,17 +26,17 @@ module Redcar
26
26
  #
27
27
  # For example:
28
28
  #
29
- # >> Application::Dialog.message_box(win, "YO!", :type => :info,
29
+ # >> Application::Dialog.message_box("YO!", :type => :info,
30
30
  # >> :buttons => :yes_no_cancel)
31
31
  # => :yes
32
- def self.message_box(window, text, options={})
32
+ def self.message_box(text, options={})
33
33
  if buttons = options[:buttons] and !available_message_box_button_combos.include?(buttons)
34
34
  raise "option :buttons must be in #{available_message_box_button_combos.inspect}"
35
35
  end
36
36
  if type = options[:type] and !available_message_box_types.include?(type)
37
37
  raise "option :type must be in #{available_message_box_button_types.inspect}"
38
38
  end
39
- Redcar.gui.dialog_adapter.message_box(window, text, options)
39
+ Redcar.gui.dialog_adapter.message_box(text, options)
40
40
  end
41
41
 
42
42
  # Returns the list of valid button combos that can be passed
@@ -61,7 +61,7 @@ module Redcar
61
61
  #
62
62
  # Example:
63
63
  #
64
- # Application::Dialog.input(win, "Number", "Please enter a big number", "101") do |text|
64
+ # Application::Dialog.input("Number", "Please enter a big number", "101") do |text|
65
65
  # if text.to_i > 100
66
66
  # nil
67
67
  # else
@@ -70,13 +70,13 @@ module Redcar
70
70
  # end
71
71
  #
72
72
  # The return value is a hash containing :button and :value.
73
- def self.input(window, title, message, initial_value="", &validator)
74
- Redcar.gui.dialog_adapter.input(window, title, message, initial_value, &validator)
73
+ def self.input(title, message, initial_value="", &validator)
74
+ Redcar.gui.dialog_adapter.input(title, message, initial_value, &validator)
75
75
  end
76
76
 
77
77
  # Shows a tool tip to the user, at the cursor location.
78
- def self.tool_tip(window, message)
79
- Redcar.gui.dialog_adapter.tool_tip(window, message)
78
+ def self.tool_tip(message)
79
+ Redcar.gui.dialog_adapter.tool_tip(message)
80
80
  end
81
81
  end
82
82
  end
@@ -0,0 +1,32 @@
1
+
2
+ module Redcar
3
+ class Application
4
+ class EventSpewer
5
+ attr_accessor :within
6
+
7
+ def initialize
8
+ @within = {}
9
+ end
10
+
11
+ def ignore?(name, *args)
12
+ !!@within[[name, args]]
13
+ end
14
+
15
+ def ignore(name, *args)
16
+ @within[[name, args]] = true
17
+ begin
18
+ yield
19
+ ensure
20
+ @within.delete([name, args])
21
+ end
22
+ end
23
+
24
+ def create(name, *args)
25
+ Redcar.plugin_manager.objects_implementing(:application_event_handler).each do |object|
26
+ handler = object.application_event_handler
27
+ handler.send(name, *args) if handler.respond_to?(name)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -13,18 +13,18 @@ module Redcar
13
13
 
14
14
  # Iterate over each entry
15
15
  def each
16
- @entries.each {|e| yield e}
16
+ entries.each {|e| yield e}
17
17
  end
18
18
 
19
19
  # Add a Redcar::MenuItem or a Redcar::Menu
20
20
  def <<(entry)
21
- @entries << entry
21
+ entries << entry
22
22
  self
23
23
  end
24
24
 
25
25
  # Number of entries in the menu
26
26
  def length
27
- @entries.length
27
+ entries.length
28
28
  end
29
29
 
30
30
  # Fetch the sub_menu with the given name
@@ -47,7 +47,7 @@ module Redcar
47
47
  def ==(other)
48
48
  return false unless length == other.length
49
49
  return false unless text == other.text
50
- @entries.zip(other.entries) do |here, there|
50
+ entries.zip(other.entries) do |here, there|
51
51
  return false unless here.class == there.class and here == there
52
52
  end
53
53
  true
@@ -62,7 +62,7 @@ module Redcar
62
62
  if here.class == other_entry.class
63
63
  here.merge(other_entry)
64
64
  else
65
- @entries[@entries.index(here)] = other_entry
65
+ entries[entries.index(here)] = other_entry
66
66
  end
67
67
  else
68
68
  self << other_entry
@@ -62,6 +62,11 @@ module Redcar
62
62
  @current_menu = old_menu
63
63
  end
64
64
 
65
+ def lazy_sub_menu(text, &block)
66
+ new_menu = LazyMenu.new(block, text)
67
+ @current_menu << new_menu
68
+ end
69
+
65
70
  def append(item)
66
71
  @current_menu << item
67
72
  end
@@ -0,0 +1,24 @@
1
+
2
+ module Redcar
3
+ class Menu
4
+ class LazyMenu < Menu
5
+
6
+ def initialize(block, text=nil)
7
+ @text = text
8
+ @block = block
9
+ end
10
+
11
+ def entries
12
+ Menu::Builder.build(&@block).entries
13
+ end
14
+
15
+ def <<(*_)
16
+ raise
17
+ end
18
+
19
+ def merge(*_)
20
+ raise
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,14 +1,15 @@
1
1
  module Redcar
2
- #
3
- # Events: new_tab (tab)
4
2
  class Notebook
5
3
  include Redcar::Model
6
4
  include Redcar::Observable
7
5
 
8
- def initialize
6
+ attr_reader :window
7
+
8
+ def initialize(window)
9
9
  @tabs = []
10
10
  @focussed_tab = nil
11
11
  @tab_handlers = Hash.new {|h,k| h[k] = [] }
12
+ @window = window
12
13
  end
13
14
 
14
15
  def length
@@ -14,7 +14,9 @@ module Redcar
14
14
  #
15
15
  # Events: close
16
16
  def close
17
- notify_listeners(:close)
17
+ Redcar.app.events.ignore(:tab_close, self) do
18
+ notify_listeners(:close)
19
+ end
18
20
  end
19
21
 
20
22
  # Focus the tab within the notebook, and gives the keyboard focus to the
@@ -22,7 +24,9 @@ module Redcar
22
24
  #
23
25
  # Events: focus
24
26
  def focus
25
- notify_listeners(:focus)
27
+ Redcar.app.events.ignore(:tab_focus, self) do
28
+ notify_listeners(:focus)
29
+ end
26
30
  end
27
31
 
28
32
  def title
@@ -1,6 +1,8 @@
1
1
 
2
2
  module Redcar
3
3
  class Window
4
+ DEFAULT_TITLE = "Redcar"
5
+
4
6
  include Redcar::Model
5
7
  include Redcar::Observable
6
8
 
@@ -21,7 +23,7 @@ module Redcar
21
23
  create_notebook
22
24
  @treebook = Treebook.new
23
25
  @speedbar = nil
24
- self.title = "Redcar"
26
+ self.title = DEFAULT_TITLE
25
27
  end
26
28
 
27
29
  def title
@@ -47,7 +49,7 @@ module Redcar
47
49
  # @events [(:new_notebook, notebook)]
48
50
  def create_notebook
49
51
  return if @notebooks.length == 2
50
- notebook = Redcar::Notebook.new
52
+ notebook = Redcar::Notebook.new(self)
51
53
  @notebooks << notebook
52
54
  if @notebooks.length == 1
53
55
  self.focussed_notebook = notebook
@@ -170,11 +172,13 @@ module Redcar
170
172
 
171
173
  # Focus the Window.
172
174
  def focus
173
- notify_listeners(:focussed, self)
175
+ Redcar.app.events.ignore(:window_focus, self) do
176
+ notify_listeners(:focussed, self)
177
+ end
174
178
  end
175
179
 
176
180
  def close
177
- ignore(:closing) do
181
+ Redcar.app.events.ignore(:window_close, self) do
178
182
  notify_listeners(:about_to_close, self)
179
183
  notebooks.each do |notebook|
180
184
  notebook.tabs.each {|tab| tab.close }
@@ -42,4 +42,20 @@ describe "Redcar::Menu::Builder DSL" do
42
42
  top_item = builder.menu.entries.last
43
43
  top_item.text.should == "Exit"
44
44
  end
45
- end
45
+
46
+ it "adds lazy submenus to the menu" do
47
+ builder = Redcar::Menu::Builder.new do
48
+ lazy_sub_menu "Export" do
49
+ item "PDF", :PDFCommand
50
+ end
51
+ end
52
+ builder.menu.length.should == 1
53
+
54
+ lazy_sub_menu = builder.menu.entries.first
55
+ lazy_sub_menu.should be_an_instance_of(Redcar::Menu::LazyMenu)
56
+
57
+ lazy_sub_menu.entries.length.should == 1
58
+ lazy_sub_menu.entries.first.text.should == "PDF"
59
+ end
60
+ end
61
+
@@ -6,7 +6,7 @@ describe Redcar::Notebook do
6
6
  end
7
7
 
8
8
  before do
9
- @notebook = Redcar::Notebook.new
9
+ @notebook = Redcar::Notebook.new(nil)
10
10
  end
11
11
 
12
12
  it "reports its length" do
@@ -0,0 +1,74 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <project name="redcar.application_swt" default="dist" basedir=".">
3
+ <!-- set global properties for this build -->
4
+ <property name="src" location="src"/>
5
+ <property name="build" location="build"/>
6
+ <property name="dist" location="lib/dist"/>
7
+ <property environment="env" />
8
+
9
+ <condition property="platform" value="osx">
10
+ <and>
11
+ <os family="mac" />
12
+ <os family="unix" />
13
+ <os arch="i386" />
14
+ </and>
15
+ </condition>
16
+
17
+ <condition property="platform" value="osx64">
18
+ <and>
19
+ <os family="mac" />
20
+ <os family="unix" />
21
+ <os arch="x86_64" />
22
+ </and>
23
+ </condition>
24
+
25
+ <condition property="platform" value="linux">
26
+ <and>
27
+ <os family="unix" />
28
+ <os arch="i386" />
29
+ </and>
30
+ </condition>
31
+
32
+ <condition property="platform" value="linux64">
33
+ <and>
34
+ <os family="unix" />
35
+ <os arch="amd64" />
36
+ </and>
37
+ </condition>
38
+
39
+ <condition property="platform" value="windows">
40
+ <os family="windows" />
41
+ </condition>
42
+
43
+ <path id="project.classpath">
44
+ <fileset dir="vendor/jface">
45
+ <include name="org.eclipse.jface.jar" />
46
+ </fileset>
47
+
48
+ <fileset dir="vendor/swt/${platform}">
49
+ <include name="*.jar" />
50
+ </fileset>
51
+ </path>
52
+
53
+ <target name="init">
54
+ <tstamp/>
55
+ <mkdir dir="${build}"/>
56
+ </target>
57
+
58
+ <target name="compile" depends="init" description="compile the source " >
59
+ <javac target="1.5" srcdir="${src}" destdir="${build}">
60
+ <classpath refid="project.classpath" />
61
+ </javac>
62
+ </target>
63
+
64
+ <target name="dist" depends="compile" description="generate the distribution" >
65
+ <mkdir dir="${dist}"/>
66
+ <jar jarfile="lib/dist/application_swt.jar" basedir="${build}"/>
67
+ </target>
68
+
69
+ <target name="clean"
70
+ description="clean up" >
71
+ <delete dir="${build}"/>
72
+ <delete dir="${dist}"/>
73
+ </target>
74
+ </project>
@@ -21,6 +21,8 @@ require "application_swt/treebook"
21
21
  require "application_swt/window"
22
22
  require "application_swt/swt/grid_data"
23
23
 
24
+ require "dist/application_swt"
25
+
24
26
  module Redcar
25
27
  class ApplicationSWT
26
28
  include Redcar::Controller
@@ -92,16 +94,93 @@ module Redcar
92
94
  shell.add_shell_listener(ShellListener.new)
93
95
  end
94
96
 
97
+ def self.shell_dialogs
98
+ @shell_dialogs ||= {}
99
+ end
100
+
101
+ def self.register_dialog(shell, dialog)
102
+ shell_dialogs[shell] = dialog
103
+ end
104
+
105
+ def self.unregister_dialog(dialog)
106
+ shell_dialogs.delete(shell_dialogs.invert[dialog])
107
+ end
108
+
95
109
  def initialize(model)
96
110
  @model = model
97
111
  add_listeners
112
+ add_swt_listeners
98
113
  create_clipboard
114
+ create_fake_window
115
+ end
116
+
117
+ def fake_shell
118
+ @fake_shell
99
119
  end
100
120
 
121
+ def create_fake_window
122
+ if Redcar.platform == :osx
123
+ @fake_shell = Swt::Widgets::Shell.new(ApplicationSWT.display, Swt::SWT::NO_TRIM)
124
+ @fake_shell.open
125
+ @fake_shell.set_size(0, 0)
126
+ end
127
+ end
128
+
129
+ class FakeWindow
130
+ def initialize(shell)
131
+ @shell = shell
132
+ end
133
+
134
+ attr_reader :shell
135
+ end
136
+
137
+ def refresh_menu
138
+ if Redcar.platform == :osx
139
+ old_menu_bar = @fake_shell.menu_bar
140
+ fake_menu_controller = ApplicationSWT::Menu.new(FakeWindow.new(@fake_shell), Redcar.app.main_menu, Redcar.app.main_keymap, Swt::SWT::BAR)
141
+ fake_shell.menu_bar = fake_menu_controller.menu_bar
142
+ old_menu_bar.dispose if old_menu_bar
143
+ end
144
+ end
145
+
101
146
  def add_listeners
102
147
  @model.add_listener(:new_window, &method(:new_window))
103
148
  end
104
149
 
150
+ class Listener
151
+ def initialize(name)
152
+ @name = name
153
+ end
154
+
155
+ def handle_event(e)
156
+ Application::Dialog.message_box("#{@name} menu is not hooked up yet")
157
+ end
158
+ end
159
+
160
+ class QuitListener
161
+ def handle_event(e)
162
+ unless Redcar.app.events.ignore?(:application_close, Redcar.app)
163
+ e.doit = false
164
+ Redcar.app.events.create(:application_close, Redcar.app)
165
+ end
166
+ end
167
+ end
168
+
169
+ def add_swt_listeners
170
+ if Redcar.platform == :osx
171
+ quit_listener = Listener.new(:quit)
172
+ about_listener = Listener.new(:about)
173
+ prefs_listener = Listener.new(:prefs)
174
+ enhancer = com.redcareditor.application_swt.CocoaUIEnhancer.new("Redcar")
175
+ enhancer.hook_application_menu(
176
+ ApplicationSWT.display,
177
+ QuitListener.new,
178
+ about_listener,
179
+ prefs_listener
180
+ )
181
+ end
182
+ end
183
+
105
184
  def create_clipboard
106
185
  ApplicationSWT::Clipboard.new(@model.clipboard)
107
186
  end