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,47 @@
1
+ Feature: Navigating web content in HtmlTabs using the browser bar
2
+
3
+ Background:
4
+ When I will choose "plugins/html_view/features/fixtures" from the "open_directory" dialog
5
+ And I open a directory
6
+ And I open the browser bar
7
+ And I type "sample.html" into the "New URL:" field in the speedbar
8
+ And I press "Go!" in the speedbar
9
+
10
+ Scenario: Refresh a tab
11
+ Given I will choose "plugins/html_view/features/fixtures/sample.html" from the "open_file" dialog
12
+ When I open a file
13
+ And I replace the contents with "<html>I see you!</html>"
14
+ And I save the tab
15
+ And I close the focussed tab
16
+ And I open the browser bar
17
+ And I press "Refresh" in the speedbar
18
+ Then the HTML tab should say "I see you!"
19
+
20
+ Scenario: Go to a new URL in a HtmlTab
21
+ When I type "other.html" into the "New URL:" field in the speedbar
22
+ And I press "Go!" in the speedbar
23
+ Then the HTML tab should say "Is today Tuesday?"
24
+
25
+ Scenario: Move back and forward in the browser history
26
+ When I type "other.html" into the "New URL:" field in the speedbar
27
+ And I press "Go!" in the speedbar
28
+ And I press "<" in the speedbar
29
+ Then the HTML tab should say "Hello!!"
30
+ When I press ">" in the speedbar
31
+ Then the HTML tab should say "Is today Tuesday?"
32
+
33
+ Scenario: View page source from the browser bar
34
+ When I press "Source" in the speedbar
35
+ Then I should see "<html><b>Hello!!</b></html>" in the edit tab
36
+
37
+ Scenario: Add a new bookmark to a project
38
+ When I type "other.html" into the "New URL:" field in the speedbar
39
+ Given I would type "Other" in an input box
40
+ And I would type "" in an input box
41
+ When I press "+" in the speedbar
42
+ And I open the web bookmarks tree
43
+ Then I should see "Other" in the tree
44
+
45
+ Scenario: When a HTML tab loses focus, the browser bar is hidden
46
+ When I open a new edit tab
47
+ Then there should not be an open speedbar
@@ -0,0 +1 @@
1
+ <html><b>Is today Tuesday?</b></html>
@@ -0,0 +1 @@
1
+ <html><b>Hello!!</b></html>
@@ -1,8 +1,8 @@
1
- Then /^the HTML tab (should say|says) "([^"]*)"$/ do |_, needle|
1
+ Then /^the HTML tab (should (not )?say|says) "([^"]*)"$/ do |_, negation, needle|
2
2
  limit = 5
3
3
  contents = nil
4
4
  started = false
5
-
5
+
6
6
  thread = Thread.new do
7
7
  started = true
8
8
  start = Time.now
@@ -10,15 +10,55 @@ Then /^the HTML tab (should say|says) "([^"]*)"$/ do |_, needle|
10
10
  while !contents or (contents and !contents.match(needle)) && Time.now - start < limit
11
11
  contents = get_browser_contents
12
12
  sleep 0.1
13
- end
13
+ end
14
14
  end
15
-
15
+
16
16
  Redcar.gui.yield_until { started && !thread.alive? }
17
17
 
18
18
  # For now, just skip on XUL platforms on which we can't get browser exec results
19
19
  # (current version of SWT and XulRunner). More info at:
20
20
  # https://bugs.eclipse.org/bugs/show_bug.cgi?id=259687
21
21
  unless (contents.nil? or contents.empty?) and [:windows, :linux].include? Redcar.platform
22
- contents.should match needle
22
+ negation ? (contents.should_not match needle) : (contents.should match needle)
23
23
  end
24
24
  end
25
+
26
+ When /^I click "([^\"]+)" in the HTML tab$/ do |link|
27
+ html_view = focussed_tab.html_view
28
+ # The JQuery way doesn't seem to work - I'm getting errors with this:
29
+ # => html_view.controller.execute(%{ $("a:contains(#{link.gsub('"', '\"')})").click(); })
30
+ # So, click the link the old-fashioned way.
31
+ js = <<-JAVASCRIPT
32
+ var link, evt, links, cancelled, i;
33
+ links = document.getElementsByTagName("a");
34
+ for (i = 0; i < links.length; i++) {
35
+ if (links[i].innerHTML.search(#{link.inspect}) > -1) {
36
+ link = links[i];
37
+ break;
38
+ }
39
+ }
40
+
41
+ if (typeof(link) !== "undefined") {
42
+ if (document.createEvent) {
43
+ evt = document.createEvent("MouseEvents");
44
+ evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
45
+ cancelled = !link.dispatchEvent(evt);
46
+ } else if (link.fireEvent) {
47
+ cancelled = !link.fireEvent("onclick");
48
+ }
49
+ if (!cancelled) {
50
+ window.location = link.href;
51
+ }
52
+ }
53
+ JAVASCRIPT
54
+
55
+ html_view.controller.execute(js)
56
+ end
57
+
58
+ When /^I open the browser bar$/ do
59
+ Redcar::HtmlView::ToggleBrowserBar.new.run
60
+ end
61
+
62
+ When /^I open a web preview$/ do
63
+ Redcar::HtmlView::FileWebPreview.new.run
64
+ end
@@ -0,0 +1,26 @@
1
+
2
+ def htmlview_fixtures_path
3
+ File.expand_path(File.dirname(__FILE__) + "/../fixtures")
4
+ end
5
+
6
+ def htmlview_fixtures_redcar
7
+ File.join(htmlview_fixtures_path,".redcar")
8
+ end
9
+
10
+ def reset_htmlview_fixtures
11
+ FileUtils.rm_rf(htmlview_fixtures_redcar) if File.exists?(htmlview_fixtures_redcar)
12
+ File.open(htmlview_fixtures_path + "/sample.html", "w") do |f|
13
+ f.print "<html><b>Hello!!</b></html>"
14
+ end
15
+ File.open(htmlview_fixtures_path + "/other.html", "w") do |f|
16
+ f.print "<html><b>Is today Tuesday?</b></html>"
17
+ end
18
+ end
19
+
20
+ Before do
21
+ reset_htmlview_fixtures
22
+ end
23
+
24
+ After do
25
+ reset_htmlview_fixtures
26
+ end
@@ -0,0 +1,21 @@
1
+ Feature: Previewing how a file will appear in a browser
2
+
3
+ Scenario: Previewing an untitled tab
4
+ When I open a new edit tab
5
+ And I replace the contents with "<html>test 1-2-3</html>"
6
+ And I open a web preview
7
+ Then my active tab should be "Preview"
8
+ And the HTML tab should say "test 1-2-3"
9
+
10
+ Scenario: Previewing a saved file
11
+ Given I will choose "plugins/html_view/features/fixtures/sample.html" from the "open_file" dialog
12
+ When I open a file
13
+ And I replace the contents with "<html>test 1-2-3</html>"
14
+ And I open a web preview
15
+ Then my active tab should be "Preview: sample.html"
16
+ And the HTML tab should say "Hello!!"
17
+ When I close the focussed tab
18
+ And I save the tab
19
+ And I open a web preview
20
+ Then my active tab should be "Preview: sample.html"
21
+ And the HTML tab should say "test 1-2-3"
@@ -2,23 +2,23 @@
2
2
  module Redcar
3
3
  module HtmlController
4
4
  include Redcar::Observable
5
-
5
+
6
6
  # Reload the index page
7
7
  def reload_index
8
8
  notify_listeners(:reload_index)
9
9
  end
10
-
10
+
11
11
  # Override this to return a message if the user should be prompted
12
12
  # before closing the tab.
13
13
  def ask_before_closing
14
14
  nil
15
15
  end
16
-
16
+
17
17
  # Override this to run code right before the tab is closed.
18
18
  def close
19
19
  nil
20
20
  end
21
-
21
+
22
22
  # Call execute with a string of javascript to execute the script
23
23
  # in the context of the browser widget.
24
24
  def execute(script)
@@ -47,4 +47,4 @@ module Redcar
47
47
  JS
48
48
  end
49
49
  end
50
- end
50
+ end
@@ -1,6 +1,9 @@
1
1
 
2
+ require 'html_view/commands'
3
+ require 'html_view/browser_bar'
2
4
  require 'html_view/html_tab'
3
5
  require 'html_controller'
6
+ require 'html_view/default_controller'
4
7
  require 'json'
5
8
 
6
9
  module Redcar
@@ -8,18 +11,67 @@ module Redcar
8
11
  def self.default_css_path
9
12
  File.expand_path(File.join(Redcar.root, %w(plugins html_view assets redcar.css)))
10
13
  end
11
-
14
+
12
15
  def self.jquery_path
13
16
  File.expand_path(File.join(Redcar.root, %w(plugins html_view assets jquery-1.4.min.js)))
14
17
  end
15
-
18
+
19
+ def self.keymaps
20
+ map = Redcar::Keymap.build("main", [:osx, :linux, :windows]) do
21
+ link "Alt+Shift+B", ToggleBrowserBar
22
+ end
23
+ [map]
24
+ end
25
+
26
+ def self.menus
27
+ Redcar::Menu::Builder.build do
28
+ sub_menu "File" do
29
+ item "Web Preview", :command => FileWebPreview, :priority => 8
30
+ end
31
+ sub_menu "View" do
32
+ item "Toggle Browser Bar", :command => ToggleBrowserBar, :priority => 11
33
+ end
34
+ end
35
+ end
36
+
37
+ def self.storage
38
+ @storage ||= begin
39
+ storage = Plugin::Storage.new('html_view')
40
+ storage.set_default('use_external_browser_for_urls', false)
41
+ storage
42
+ end
43
+ end
44
+
45
+ def self.show_browser_bar?
46
+ if win = Redcar.app.focussed_window and
47
+ win.speedbar and win.speedbar.is_a?(BrowserBar)
48
+ return true
49
+ end
50
+ false
51
+ end
52
+
53
+ def self.tidy_url(url)
54
+ unless url.include?("://")
55
+ if File.exists?(url)
56
+ url = "file://#{url}"
57
+ elsif project = Redcar::Project::Manager.focussed_project and
58
+ relpath = File.join(project.path,url) and
59
+ File.exists?(relpath)
60
+ url = "file://#{relpath}"
61
+ else
62
+ url = "http://#{url}"
63
+ end
64
+ end
65
+ url
66
+ end
67
+
16
68
  attr_reader :controller
17
-
69
+
18
70
  def initialize(html_tab)
19
71
  @html_tab = html_tab
20
72
  @html_tab.add_listener(:controller_action, &method(:controller_action))
21
73
  end
22
-
74
+
23
75
  def controller=(new_controller)
24
76
  @controller = new_controller
25
77
  @html_tab.title = controller.title
@@ -28,7 +80,7 @@ module Redcar
28
80
  controller_action("index")
29
81
  attach_controller_listeners
30
82
  end
31
-
83
+
32
84
  def attach_controller_listeners
33
85
  @controller.add_listener(:reload_index) { controller_action("index") }
34
86
 
@@ -53,7 +105,7 @@ module Redcar
53
105
  result
54
106
  end
55
107
  end
56
-
108
+
57
109
  def controller_action(action_name, params=nil)
58
110
  text = nil
59
111
  begin
@@ -78,13 +130,13 @@ module Redcar
78
130
  end
79
131
  end
80
132
  end
81
-
133
+
82
134
  def contents=(source)
83
135
  @html_tab.controller.browser.set_text(source)
84
136
  end
85
-
137
+
86
138
  private
87
-
139
+
88
140
  class RubyFunc < Swt::Browser::BrowserFunction
89
141
  def function(args)
90
142
  begin
@@ -101,7 +153,7 @@ module Redcar
101
153
  puts e.backtrace
102
154
  end
103
155
  end
104
-
156
+
105
157
  attr_accessor :controller
106
158
  end
107
159
 
@@ -1,8 +1,15 @@
1
1
 
2
2
  module Redcar
3
- class WebBookmarks
3
+ class HtmlView
4
4
  class BrowserBar < Redcar::Speedbar
5
5
 
6
+ def tab_changed(tab)
7
+ unless tab.is_a?(HtmlTab)
8
+ win = Redcar.app.focussed_window
9
+ win.close_speedbar
10
+ end
11
+ end
12
+
6
13
  def html_tab
7
14
  tab = Redcar.app.focussed_window.focussed_notebook_tab
8
15
  tab if tab.is_a?(Redcar::HtmlTab)
@@ -31,25 +38,26 @@ module Redcar
31
38
  end
32
39
 
33
40
  button :source, "Source", nil do
34
- tab = Redcar.app.focussed_window.new_tab(Redcar::EditTab)
35
- url = html_tab.controller.browser.url.to_s
36
- if url =~ /^file:\/\//
37
- file_path = url[7,url.length]
38
- mirror = Project::FileMirror.new(file_path)
39
- tab.edit_view.document.mirror = mirror
40
- else
41
- tab.edit_view.document.text = html_tab.controller.browser.text
42
- tab.title = "Page Source"
41
+ if html = html_tab and url = html.controller.browser.url.to_s
42
+ tab = Redcar.app.focussed_window.new_tab(Redcar::EditTab)
43
+ if url =~ /^file:\/\//
44
+ file_path = url[7,url.length]
45
+ mirror = Redcar::Project::FileMirror.new(file_path)
46
+ tab.edit_view.document.mirror = mirror
47
+ else
48
+ tab.edit_view.document.text = html_tab.controller.browser.text
49
+ tab.title = "Page Source"
50
+ end
51
+ tab.edit_view.grammar = "HTML"
52
+ tab.edit_view.reset_undo
53
+ tab.focus
43
54
  end
44
- tab.edit_view.grammar = "HTML"
45
- tab.edit_view.reset_undo
46
- tab.focus
47
55
  end
48
56
 
49
57
  button :add, "+", nil do
50
58
  if tab = html_tab and
51
59
  url = tab.controller.browser.url.to_s
52
- WebBookmarks::AddBookmark.new(url).run
60
+ Redcar::WebBookmarks::AddBookmark.new(url).run
53
61
  end
54
62
  end
55
63
 
@@ -57,14 +65,18 @@ module Redcar
57
65
  textbox :new_url
58
66
 
59
67
  button :go_to_url, "Go!", "Return" do
60
- @tab = html_tab
61
- if @tab
62
- unless new_url.value == ""
63
- @tab.title=new_url.value
64
- @tab.controller.go_to_location(new_url.value)
68
+ unless new_url.value == ""
69
+ url = new_url.value
70
+ if tab = html_tab
71
+ tab.title = url
72
+ tab.controller.go_to_location(HtmlView.tidy_url(url))
73
+ icon = HtmlTab.web_content_icon
74
+ tab.icon = icon unless tab.icon == icon
75
+ else
76
+ Redcar::HtmlView::DisplayWebContent.new(url,url).run
65
77
  end
66
78
  end
67
79
  end
68
80
  end
69
81
  end
70
- end
82
+ end
@@ -0,0 +1,64 @@
1
+ require 'java'
2
+
3
+ module Redcar
4
+ class HtmlView
5
+
6
+ # Open a HtmlTab for displaying web content
7
+ class DisplayWebContent < Redcar::Command
8
+ def initialize(name,url,display_bar=true,tab_class=HtmlTab)
9
+ @name = name
10
+ @url = url
11
+ @display_bar = display_bar
12
+ @tab = tab_class
13
+ end
14
+
15
+ def execute
16
+ use_external = HtmlView.storage['use_external_browser_for_urls']
17
+ if use_external and OpenDefaultBrowserCommand.supported?
18
+ OpenDefaultBrowserCommand.new(@url).run
19
+ else
20
+ win = Redcar.app.focussed_window
21
+ controller = DefaultController.new(@name,@url)
22
+ tab = win.new_tab(@tab)
23
+ tab.html_view.controller = controller
24
+ tab.icon = HtmlTab.web_content_icon if tab.is_a?(HtmlTab)
25
+ tab.focus
26
+ if @display_bar and not HtmlView.show_browser_bar?
27
+ HtmlView::ToggleBrowserBar.new.run
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ class FileWebPreview < Redcar::EditTabCommand
34
+ def execute
35
+ mirror = doc.mirror
36
+ if mirror and path = mirror.path and File.exists?(path)
37
+ name = "Preview: " +File.basename(path)
38
+ else
39
+ name = "Preview"
40
+ preview = java.io.File.createTempFile("preview","html")
41
+ preview.deleteOnExit
42
+ path = preview.getAbsolutePath
43
+ File.open(path,'w') {|f| f.puts(doc.get_all_text)}
44
+ end
45
+ url = File.expand_path(path)
46
+ DisplayWebContent.new(name,url).run
47
+ end
48
+ end
49
+
50
+ class ToggleBrowserBar < Redcar::Command
51
+ sensitize :open_htmltab
52
+ def execute
53
+ if win = Redcar.app.focussed_window
54
+ if HtmlView.show_browser_bar?
55
+ win.close_speedbar
56
+ else
57
+ speedbar = Redcar::HtmlView::BrowserBar.new
58
+ win.open_speedbar(speedbar)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end