redcar 0.7 → 0.8

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 (131) hide show
  1. data/CHANGES +42 -0
  2. data/README.md +5 -3
  3. data/Rakefile +39 -81
  4. data/bin/redcar +1 -1
  5. data/lib/redcar.rb +9 -6
  6. data/lib/redcar/installer.rb +1 -1
  7. data/lib/redcar/ruby_extensions.rb +19 -0
  8. data/lib/redcar/runner.rb +1 -1
  9. data/lib/redcar/usage.rb +3 -0
  10. data/lib/redcar_quick_start.rb +11 -11
  11. data/plugins/application/features/step_definitions/tree_steps.rb +22 -5
  12. data/plugins/application/features/step_definitions/window_steps.rb +9 -1
  13. data/plugins/application/features/support/env.rb +5 -2
  14. data/plugins/application/lib/application.rb +51 -46
  15. data/plugins/application/lib/application/window.rb +60 -30
  16. data/plugins/application_swt/lib/application_swt.rb +16 -16
  17. data/plugins/application_swt/lib/application_swt/window.rb +35 -7
  18. data/plugins/auto_completer/features/support/env.rb +0 -2
  19. data/plugins/auto_indenter/features/support/env.rb +0 -1
  20. data/plugins/auto_pairer/features/auto_pairer.feature +50 -45
  21. data/plugins/auto_pairer/features/support/env.rb +0 -1
  22. data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +11 -6
  23. data/plugins/clipboard-viewer/Screenshot.png +0 -0
  24. data/plugins/clipboard-viewer/lib/clipboard_viewer.rb +50 -0
  25. data/plugins/clipboard-viewer/lib/clipboard_viewer/browser_controller.rb +27 -0
  26. data/plugins/clipboard-viewer/lib/clipboard_viewer/clipboard_bar.rb +67 -0
  27. data/plugins/clipboard-viewer/plugin.rb +9 -0
  28. data/plugins/clipboard-viewer/views/clipboard.html.erb +15 -0
  29. data/plugins/clipboard-viewer/views/default.css +43 -0
  30. data/plugins/clipboard-viewer/views/redcar_small_icon.png +0 -0
  31. data/plugins/comment/features/line_comment.feature +137 -0
  32. data/plugins/comment/features/selection_comment.feature +21 -0
  33. data/plugins/comment/features/step_definitions/comment_steps.rb +7 -0
  34. data/plugins/comment/lib/comment.rb +266 -0
  35. data/plugins/comment/plugin.rb +7 -0
  36. data/plugins/comment/vendor/comment_lib.json +47 -0
  37. data/plugins/declarations/lib/declarations.rb +1 -1
  38. data/plugins/document_search/features/replace.feature +10 -2
  39. data/plugins/document_search/features/support/env.rb +0 -1
  40. data/plugins/document_search/lib/document_search.rb +4 -1
  41. data/plugins/document_search/lib/document_search/replace.rb +11 -3
  42. data/plugins/document_search/lib/document_search/search_and_replace.rb +5 -2
  43. data/plugins/edit_view/features/case_change.feature +9 -9
  44. data/plugins/edit_view/features/cursor_navigation.feature +36 -0
  45. data/plugins/edit_view/features/step_definitions/editing_steps.rb +63 -8
  46. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +2 -0
  47. data/plugins/edit_view/features/step_definitions/tab_steps.rb +8 -5
  48. data/plugins/edit_view/features/support/env.rb +8 -2
  49. data/plugins/edit_view/lib/edit_view.rb +16 -1
  50. data/plugins/edit_view/lib/edit_view/actions/cmd_enter.rb +11 -0
  51. data/plugins/edit_view/lib/edit_view/document.rb +27 -10
  52. data/plugins/edit_view/lib/edit_view/edit_tab.rb +17 -4
  53. data/plugins/edit_view/spec/edit_view/document_spec.rb +3 -0
  54. data/plugins/edit_view_swt/lib/edit_view_swt.rb +42 -3
  55. data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +17 -15
  56. data/plugins/help/lib/help.rb +40 -0
  57. data/plugins/help/plugin.rb +8 -0
  58. data/plugins/html_view/features/step_definitions/html_view_steps.rb +6 -4
  59. data/plugins/line_tools/features/support/env.rb +0 -1
  60. data/plugins/macros/features/step_definitions/macro_steps.rb +0 -55
  61. data/plugins/macros/features/support/env.rb +0 -2
  62. data/plugins/open_default_app/lib/open_default_app.rb +35 -0
  63. data/plugins/open_default_app/plugin.rb +8 -0
  64. data/plugins/open_default_app/screenshot.png +0 -0
  65. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +17 -3
  66. data/plugins/project/features/find_file.feature +3 -2
  67. data/plugins/project/features/highlight_focussed_tab.feature +8 -0
  68. data/plugins/project/features/move_and_rename_files.feature +25 -0
  69. data/plugins/project/features/open_and_save_files.feature +10 -1
  70. data/plugins/project/features/open_directory_tree.feature +32 -2
  71. data/plugins/project/features/step_definitions/directory_steps.rb +17 -0
  72. data/plugins/project/features/step_definitions/project_tree_steps.rb +3 -0
  73. data/plugins/project/features/sub_project.feature +14 -0
  74. data/plugins/project/features/support/env.rb +22 -3
  75. data/plugins/project/features/watch_for_modified_files.feature +32 -9
  76. data/plugins/project/lib/project.rb +53 -21
  77. data/plugins/project/lib/project/adapters/local.rb +21 -16
  78. data/plugins/project/lib/project/adapters/remote.rb +15 -13
  79. data/plugins/project/lib/project/commands.rb +37 -16
  80. data/plugins/project/lib/project/dir_controller.rb +41 -42
  81. data/plugins/project/lib/project/drb_service.rb +35 -21
  82. data/plugins/project/lib/project/file_list.rb +7 -1
  83. data/plugins/project/lib/project/manager.rb +28 -3
  84. data/plugins/project/lib/project/sub_project.rb +17 -0
  85. data/plugins/project/lib/project/support/recycle.js +2 -0
  86. data/plugins/project/lib/project/support/trash.rb +72 -0
  87. data/plugins/project/spec/fixtures/multi-byte-files/a/341/204/200/341/205/247/341/206/274/341/204/205/341/205/251/foo +1 -0
  88. data/plugins/project/spec/fixtures/multi-byte-files//341/204/220/341/205/246/341/204/211/341/205/263/341/204/220/341/205/263.py +1 -0
  89. data/plugins/project/spec/project/file_list_spec.rb +4 -0
  90. data/plugins/redcar/features/goto_line_command.feature +20 -0
  91. data/plugins/redcar/redcar.rb +107 -47
  92. data/plugins/repl/lib/repl.rb +20 -20
  93. data/plugins/repl/lib/repl/clojure_mirror.rb +50 -58
  94. data/plugins/repl/lib/repl/groovy_mirror.rb +22 -41
  95. data/plugins/repl/lib/repl/repl_mirror.rb +85 -14
  96. data/plugins/repl/lib/repl/ruby_mirror.rb +12 -39
  97. data/plugins/repl/spec/repl/groovy_mirror_spec.rb +1 -1
  98. data/plugins/repl/spec/repl/ruby_mirror_spec.rb +12 -12
  99. data/plugins/ruby/README +6 -0
  100. data/plugins/ruby/lib/syntax_check/ruby.rb +28 -0
  101. data/plugins/ruby/plugin.rb +7 -0
  102. data/plugins/runnables/features/command_tree.feature +9 -0
  103. data/plugins/runnables/features/file_runner_input.feature +20 -0
  104. data/plugins/runnables/features/run_alternate_command.feature +14 -0
  105. data/plugins/runnables/features/support/env.rb +42 -5
  106. data/plugins/runnables/lib/runnables.rb +67 -21
  107. data/plugins/runnables/lib/runnables/commands.rb +35 -18
  108. data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_group.rb +23 -37
  109. data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_type_group.rb +16 -18
  110. data/plugins/scm_svn/features/support/env.rb +0 -3
  111. data/plugins/snippets/features/snippets.feature +17 -2
  112. data/plugins/snippets/features/support/env.rb +0 -1
  113. data/plugins/snippets/lib/snippets/tab_handler.rb +51 -18
  114. data/plugins/swt/lib/swt/cucumber_patches.rb +13 -68
  115. data/plugins/swt/lib/swt/cucumber_runner.rb +2 -3
  116. data/plugins/syntax_check/README +6 -0
  117. data/plugins/syntax_check/lib/syntax_check.rb +16 -0
  118. data/plugins/syntax_check/lib/syntax_check/checker.rb +47 -0
  119. data/plugins/syntax_check/lib/syntax_check/error.rb +23 -0
  120. data/plugins/syntax_check/plugin.rb +7 -0
  121. data/plugins/tree_view_swt/lib/tree_view_swt.rb +6 -0
  122. data/plugins/web_bookmarks/Screenshot.png +0 -0
  123. data/plugins/web_bookmarks/lib/web_bookmarks.rb +42 -0
  124. data/plugins/web_bookmarks/lib/web_bookmarks/bookmark.rb +43 -0
  125. data/plugins/web_bookmarks/lib/web_bookmarks/browser_bar.rb +70 -0
  126. data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +111 -0
  127. data/plugins/web_bookmarks/lib/web_bookmarks/tree.rb +67 -0
  128. data/plugins/web_bookmarks/lib/web_bookmarks/view_controller.rb +22 -0
  129. data/plugins/web_bookmarks/plugin.rb +11 -0
  130. data/plugins/web_bookmarks/views/index.html.erb +5 -0
  131. metadata +60 -10
@@ -0,0 +1,8 @@
1
+
2
+ Plugin.define do
3
+ name "open_default_app"
4
+ version "0.1"
5
+ file "lib", "open_default_app.rb"
6
+ object "Redcar::OpenDefaultApp"
7
+ dependencies "redcar", ">0"
8
+ end
@@ -12,14 +12,28 @@ module Redcar
12
12
  sub_menu "Plugins", :priority => 40 do
13
13
  group(:priority => :first) {
14
14
  item "Plugin Manager", PluginManagerUi::OpenCommand
15
- item "Reload Again", PluginManagerUi::ReloadLastReloadedCommand
16
- item("Edit Preferences") { Project::Manager.open_project_for_path(Redcar::Plugin::Storage.storage_dir) }
15
+ item "Reload Plugins", PluginManagerUi::ReloadLastReloadedCommand
17
16
  separator
18
17
  }
19
18
  end
19
+ if Redcar.platform == :linux or Redcar.platform == :windows
20
+ sub_menu "Edit" do
21
+ group(:priority => :last) do
22
+ separator
23
+ item "Preferences", PluginManagerUi::OpenPreferencesCommand
24
+ end
25
+ end
26
+ end
20
27
  end
21
28
  end
22
-
29
+
30
+ class OpenPreferencesCommand < Redcar::Command
31
+ def execute
32
+ project = Project::Manager.open_project_for_path(Redcar::Plugin::Storage.storage_dir)
33
+ project.window.title = "Plugin Preferences"
34
+ end
35
+ end
36
+
23
37
  class ReloadLastReloadedCommand < Redcar::Command
24
38
 
25
39
  def execute
@@ -26,9 +26,10 @@ Feature: Find file
26
26
  When I run the command Redcar::Project::FindFileCommand
27
27
  And I set the filter to "foo"
28
28
  And I wait "0.4" seconds
29
- Then the filter dialog should have 2 entries
29
+ Then the filter dialog should have 3 entries
30
30
  And I should see "foo_lib.rb (myproject/lib)" at 0 the filter dialog
31
- And I should see "foo_spec.rb (myproject/spec)" at 1 the filter dialog
31
+ And I should see "foo_lib.rb (myproject/lib_symlink)" at 1 the filter dialog
32
+ And I should see "foo_spec.rb (myproject/spec)" at 2 the filter dialog
32
33
 
33
34
  Scenario: One matching file with arbitrary letters
34
35
  When I run the command Redcar::Project::FindFileCommand
@@ -0,0 +1,8 @@
1
+ Feature: Highlight the File of the focussed tab in tree
2
+
3
+ Scenario: Opening a file should reveal it in the tree
4
+ Given I will choose "." from the "open_directory" dialog
5
+ And I open a directory
6
+ And I have opened "plugins/project/features/highlight_focussed_tab.feature"
7
+ Then there should be one edit tab
8
+ And "highlight_focussed_tab.feature" should be selected in the project tree
@@ -0,0 +1,25 @@
1
+ # Feature: Moving and renaming files
2
+
3
+ # Background:
4
+ # Given I will choose "plugins/project/spec/fixtures/myproject" from the "open_directory" dialog
5
+ # When I open a directory
6
+ #
7
+ # Scenario: Renaming a file which is currently open
8
+ # Given I will choose "plugins/project/spec/fixtures/myproject/test1/a.txt" from the "open_file" dialog
9
+ # When I open a file
10
+ # Given I will choose "summer.txt" as the rename text
11
+ # When I rename the "a.txt" node in the tree
12
+ # Then my active tab should be "summer.txt"
13
+ #
14
+ # Scenario: Bulk renaming files which are currently open
15
+ # Given I will choose "plugins/project/spec/fixtures/myproject/test1/a.txt" from the "open_file" dialog
16
+ # When I open a file
17
+ # Given I will choose "plugins/project/spec/fixtures/myproject/test1/b.txt" from the "open_file" dialog
18
+ # When I open a file
19
+ # And I bulk rename the "a.txt,b.txt" nodes in the tree replacing "" with "Test"
20
+ # Then my active tab should be "Testb.txt"
21
+ # When I close the focussed tab
22
+ # Then my active tab should be "Testa.txt"
23
+
24
+ # There isn't a good way to simulate file rename text entry at this moment
25
+
@@ -14,7 +14,7 @@ Feature: Open and save files
14
14
  And I open a file
15
15
  Then there should be 2 edit tabs
16
16
  And I should see "Wintersmith" in the edit tab
17
-
17
+
18
18
  Scenario: Save a file
19
19
  Given I have opened "plugins/project/spec/fixtures/winter.txt"
20
20
  When I replace the contents with "Hi!"
@@ -29,3 +29,12 @@ Feature: Open and save files
29
29
  Then the file "plugins/project/spec/fixtures/winter2.txt" should contain "Wintersmith"
30
30
  And I should see "Wintersmith" in the edit tab
31
31
 
32
+ Scenario: Open file in nearest ancestor project window
33
+ Given I will choose "plugins/project/spec" from the "open_directory" dialog
34
+ When I open a directory
35
+ Given I will choose "plugins/project/spec/fixtures" from the "open_directory" dialog
36
+ When I open a directory
37
+ Given I will choose "plugins/project/spec/fixtures/winter.txt" from the "open_file" dialog
38
+ When I open a file
39
+ Then the window "fixtures" should have 1 tab
40
+
@@ -11,7 +11,7 @@ Feature: Open directory tree
11
11
  Given I will choose "plugins" from the "open_directory" dialog
12
12
  When I open a directory
13
13
  Then I should see "core,application,tree" in the tree
14
-
14
+
15
15
  Scenario: Title of window reflects open project
16
16
  Given I will choose "plugins/project/spec/fixtures/myproject" from the "open_directory" dialog
17
17
  When I open a directory
@@ -32,4 +32,34 @@ Feature: Open directory tree
32
32
  Then the tree width should be the default
33
33
  When I restore the window size
34
34
  Then the tree width should be the default
35
-
35
+
36
+ Scenario: Toggle Tree Visibility hides the treebook if the sash is visible, else it opens it
37
+ Given I will choose "plugins/project/spec/fixtures/myproject" from the "open_directory" dialog
38
+ When I open a directory
39
+ Then the tree width should be the default
40
+ When I toggle tree visibility
41
+ Then the tree width should be 0
42
+ When I manually widen the treebook to show the sash
43
+ And I toggle tree visibility
44
+ Then the tree width should be 0
45
+ When I manually widen the treebook only a few pixels
46
+ And I toggle tree visibility
47
+ Then the tree width should be the default
48
+
49
+ Scenario: Treebook becomes visible if hidden and another tree is opened
50
+ Given I will choose "plugins/project/spec/fixtures/myproject" from the "open_directory" dialog
51
+ When I open a directory
52
+ Then the tree width should be the default
53
+ When I toggle tree visibility
54
+ Then the tree width should be 0
55
+ When I open the runnables tree
56
+ Then the tree width should be the default
57
+ And I toggle tree visibility
58
+ Then the tree width should be 0
59
+
60
+ # RSpec matchers have trouble with the multibyte string
61
+ # Scenario: Multibyte files and directories
62
+ # Given I will choose "plugins/project/spec/fixtures/multi-byte-files" from the "open_directory" dialog
63
+ # When I open a directory
64
+ # Then the window should have title "multi-byte-files"
65
+ # Then I should see "a경로,테스트.py" in the tree
@@ -15,4 +15,21 @@ When /^I move the myproject fixture away$/ do
15
15
  FileUtils.mv("plugins/project/spec/fixtures/myproject",
16
16
  "plugins/project/spec/fixtures/myproject.bak")
17
17
  @put_myproject_fixture_back = true
18
+ end
19
+
20
+ When /^I open a "([^"]*)" as a subproject of the current directory$/ do |arg1|
21
+ path = Redcar::Project::Manager.focussed_project.path
22
+ Redcar::Project::Manager.open_subproject(path,path + arg1)
23
+ end
24
+
25
+ Then /^"([^"]*)" in the project configuration files$/ do |arg1|
26
+ project = Redcar::Project::Manager.focussed_project
27
+ project.config_files(arg1).each do |file|
28
+ File.exist?(file).should == true
29
+ end
30
+ end
31
+
32
+ When /^"([^"]*)" goes missing$/ do |arg1|
33
+ FileUtils.rm(arg1)
34
+ File.exists?(arg1).should == false
18
35
  end
@@ -0,0 +1,3 @@
1
+ Then /^"([^\"]*)" should be selected in the project tree$/ do |filename|
2
+ Redcar.app.focussed_window.treebook.focussed_tree.selection.first.text == filename
3
+ end
@@ -0,0 +1,14 @@
1
+ Feature: Opening subprojects with shared configuration files
2
+
3
+ Background:
4
+ Given I will choose "plugins/project/spec/fixtures/myproject" from the "open_directory" dialog
5
+ When I open a directory
6
+
7
+ Scenario: Opening a subproject
8
+ When I open a "/test1" as a subproject of the current directory
9
+ Then I should see "a.txt,b.txt,c.txt" in the tree
10
+ And "test_config" in the project configuration files
11
+
12
+ Scenario: Title of window reflects open subproject
13
+ When I open a "/test1" as a subproject of the current directory
14
+ Then the window should have title "Subproject: test1 in myproject"
@@ -1,4 +1,7 @@
1
- RequireSupportFiles File.dirname(__FILE__) + "/../../../edit_view/features/"
1
+
2
+ def fixtures_path
3
+ File.expand_path(File.dirname(__FILE__) + "/../../spec/fixtures")
4
+ end
2
5
 
3
6
  def reset_project_fixtures
4
7
  if @put_myproject_fixture_back
@@ -6,9 +9,24 @@ def reset_project_fixtures
6
9
  FileUtils.mv("plugins/project/spec/fixtures/myproject.bak",
7
10
  "plugins/project/spec/fixtures/myproject")
8
11
  end
9
- fixtures_path = File.expand_path(File.dirname(__FILE__) + "/../../spec/fixtures")
10
12
  File.open(fixtures_path + "/winter.txt", "w") {|f| f.print "Wintersmith" }
11
13
  FileUtils.rm_rf(fixtures_path + "/winter2.txt")
14
+ make_subproject_fixtures
15
+ end
16
+
17
+ def make_subproject_fixtures
18
+ FileUtils.mkdir_p(fixtures_path + "/myproject/test1")
19
+ FileUtils.mkdir_p(fixtures_path + "/myproject/test2")
20
+ FileUtils.mkdir_p(fixtures_path + "/myproject/.redcar")
21
+ File.open(fixtures_path + "/myproject/.redcar/test_config", "w") {|f| f.print "this is a config file" }
22
+ File.open(fixtures_path + "/myproject/test1/a.txt", "w") {|f| f.print "this is a project file" }
23
+ File.open(fixtures_path + "/myproject/test1/b.txt", "w") {|f| f.print "this is a project file" }
24
+ File.open(fixtures_path + "/myproject/test1/c.txt", "w") {|f| f.print "this is a project file" }
25
+ end
26
+
27
+ def delete_subproject_fixtures
28
+ FileUtils.rm_rf(fixtures_path + "/myproject/test1")
29
+ FileUtils.rm_rf(fixtures_path + "/myproject/test2")
12
30
  end
13
31
 
14
32
  Before do
@@ -17,4 +35,5 @@ end
17
35
 
18
36
  After do
19
37
  reset_project_fixtures
20
- end
38
+ delete_subproject_fixtures
39
+ end
@@ -1,11 +1,11 @@
1
1
  Feature: Watch for modified files
2
2
  If an open file has changed on disc since the last time the user looked at it,
3
3
  then reload the contents. Alert the user if they have made modifications.
4
-
4
+
5
5
  Background:
6
6
  Given I will choose "plugins/project/spec/fixtures/winter.txt" from the "open_file" dialog
7
7
  When I open a file
8
-
8
+
9
9
  Scenario: Without modifications
10
10
  Then there should be one edit tab
11
11
  And I should see "Wintersmith" in the edit tab
@@ -25,7 +25,7 @@ Feature: Watch for modified files
25
25
  Given I will choose "yes" from the "message_box" dialog
26
26
  And I close the focussed tab
27
27
  Then I should see "Summer" in the edit tab
28
-
28
+
29
29
  Scenario: With modifications, keeping modified version
30
30
  Then there should be one edit tab
31
31
  And I should see "Wintersmith" in the edit tab
@@ -36,7 +36,7 @@ Feature: Watch for modified files
36
36
  Given I will choose "no" from the "message_box" dialog
37
37
  And I close the focussed tab
38
38
  Then I should see "Newton" in the edit tab
39
-
39
+
40
40
  Scenario: With modifications, keeping modified version, twice
41
41
  Then there should be one edit tab
42
42
  And I should see "Wintersmith" in the edit tab
@@ -50,7 +50,7 @@ Feature: Watch for modified files
50
50
  When I open a new edit tab
51
51
  Then I should not see a "message_box" dialog for the rest of the feature
52
52
  And I close the focussed tab
53
-
53
+
54
54
  Scenario: Keep in the same position in the file when reloading
55
55
  Given I close the focussed tab
56
56
  And I put a lot of lines into the file "plugins/project/spec/fixtures/winter.txt"
@@ -62,7 +62,7 @@ Feature: Watch for modified files
62
62
  And I put a lot of lines into the file "plugins/project/spec/fixtures/winter.txt"
63
63
  And I close the focussed tab
64
64
  Then the cursor should be on line 100
65
-
65
+
66
66
  Scenario: Move to the top if the line you were on is no longer there
67
67
  Given I close the focussed tab
68
68
  And I put a lot of lines into the file "plugins/project/spec/fixtures/winter.txt"
@@ -74,6 +74,29 @@ Feature: Watch for modified files
74
74
  And I put "Summer" into the file "plugins/project/spec/fixtures/winter.txt"
75
75
  And I close the focussed tab
76
76
  Then the cursor should be on line 0
77
-
78
-
79
-
77
+
78
+ Scenario: The file being mirrored by the current unmodified tab is externally deleted
79
+ Then there should be one edit tab
80
+ And I should see "Wintersmith" in the edit tab
81
+ When I open a new window with title "new"
82
+ When I wait "2" seconds
83
+ And "plugins/project/spec/fixtures/winter.txt" goes missing
84
+ And I close the window "new" through the gui
85
+ And I focus the window "Redcar" through the gui
86
+ Then there should be one edit tab
87
+ And my active tab should have an "exclamation" icon
88
+
89
+ Scenario: The file being mirrored by the current modified tab is externally deleted
90
+ Then there should be one edit tab
91
+ And I should see "Wintersmith" in the edit tab
92
+ When I replace the contents with "Jenny Green Eyes"
93
+ And I open a new window with title "new"
94
+ And I wait "2" seconds
95
+ And "plugins/project/spec/fixtures/winter.txt" goes missing
96
+ And I close the window "new" through the gui
97
+ And I focus the window "Redcar" through the gui
98
+ Then my active tab should have an "exclamation" icon
99
+ When I save the tab
100
+ Then my active tab should have an "file" icon
101
+
102
+
@@ -17,6 +17,8 @@ require "project/adapters/remote_protocols/ftp"
17
17
  require "project/adapters/local"
18
18
  require "project/adapters/remote"
19
19
 
20
+ require "project/support/trash"
21
+
20
22
  require "project/commands"
21
23
  require "project/dir_mirror"
22
24
  require "project/dir_controller"
@@ -26,20 +28,23 @@ require "project/file_mirror"
26
28
  require "project/find_file_dialog"
27
29
  require "project/manager"
28
30
  require "project/recent_directories"
31
+ require "project/sub_project"
29
32
 
30
33
  module Redcar
31
34
  class Project
32
35
  RECENT_FILES_LENGTH = 20
33
-
36
+
34
37
  def self.window_projects
35
38
  @window_projects ||= {}
36
39
  end
37
-
40
+
38
41
  attr_reader :window, :tree, :path, :adapter
42
+ attr_accessor :listeners
39
43
 
40
44
  def initialize(path, adapter=Adapters::Local.new)
41
45
  @adapter = adapter
42
46
  @path = File.expand_path(path)
47
+ @listeners ||= {}
43
48
  dir_mirror = Project::DirMirror.new(@path, adapter)
44
49
  if dir_mirror.exists?
45
50
  @tree = Tree.new(dir_mirror, Project::DirController.new)
@@ -49,11 +54,11 @@ module Redcar
49
54
  raise "#{path} doesn't seem to exist"
50
55
  end
51
56
  end
52
-
57
+
53
58
  def remote?
54
59
  adapter.is_a?(Adapters::Remote)
55
60
  end
56
-
61
+
57
62
  def ready?
58
63
  @tree && @path
59
64
  end
@@ -61,13 +66,14 @@ module Redcar
61
66
  def inspect
62
67
  "<Project #{path}>"
63
68
  end
64
-
69
+
65
70
  def open(win)
66
71
  @window = win
67
72
  if current_project = Project.window_projects[window]
68
73
  current_project.close
69
74
  end
70
75
  window.treebook.add_tree(@tree)
76
+ attach_listeners
71
77
  window.title = File.basename(@tree.tree_mirror.path)
72
78
  Manager.open_project_sensitivity.recompute
73
79
  Redcar.plugin_manager.objects_implementing(:project_loaded).each do |i|
@@ -77,7 +83,7 @@ module Redcar
77
83
  Manager.storage['last_open_dir'] = path
78
84
  Project.window_projects[window] = self
79
85
  end
80
-
86
+
81
87
  def close
82
88
  window.treebook.remove_tree(@tree)
83
89
  Project.window_projects.delete(window)
@@ -86,26 +92,52 @@ module Redcar
86
92
  Redcar.plugin_manager.objects_implementing(:project_closed).each do |i|
87
93
  i.project_closed(self)
88
94
  end
95
+ listeners = {}
96
+ end
97
+
98
+ def attach_listeners
99
+ window.add_listener(:notebook_focussed, &method(:notebook_focussed))
100
+ window.add_listener(:notebook_closed, &method(:notebook_closed))
101
+ window.add_listener(:notebook_added, &method(:notebook_added))
102
+ if notebooks = window.notebooks
103
+ notebooks.each do |nb|
104
+ notebook_added(nb)
105
+ end
106
+ end
107
+ end
108
+
109
+ def notebook_focussed(notebook)
110
+ RevealInProjectCommand.new.run if notebook.focussed_tab && tree
111
+ end
112
+
113
+ def notebook_added(notebook)
114
+ @listeners.merge!(notebook => notebook.add_listener(:tab_focussed) do |tab|
115
+ RevealInProjectCommand.new.run if tree
116
+ end)
117
+ end
118
+
119
+ def notebook_closed(notebook)
120
+ @listeners.delete(notebook)
89
121
  end
90
-
91
- # Refresh the DirMirror Tree for the given Window, if
122
+
123
+ # Refresh the DirMirror Tree for the given Window, if
92
124
  # there is one.
93
125
  def refresh
94
126
  @tree.refresh
95
127
  file_list_resource.compute unless remote?
96
128
  end
97
-
129
+
98
130
  def contains_path?(path)
99
131
  File.expand_path(path) =~ /^#{Regexp.escape(@path)}($|\/|\\)/
100
132
  end
101
-
133
+
102
134
  # A list of files previously opened in this session for this project
103
135
  #
104
136
  # @return [Array<String>] an array of paths
105
137
  def recent_files
106
138
  @recent_files ||= []
107
139
  end
108
-
140
+
109
141
  def add_to_recent_files(new_file)
110
142
  new_file = File.expand_path(new_file)
111
143
  if recent_files.include?(new_file)
@@ -116,54 +148,54 @@ module Redcar
116
148
  recent_files.shift
117
149
  end
118
150
  end
119
-
151
+
120
152
  def file_list
121
153
  raise "can't access a file list for a remote project" if remote?
122
154
  @file_list ||= FileList.new(path)
123
155
  end
124
-
156
+
125
157
  def file_list_resource
126
158
  @resource ||= Resource.new("refresh file list for #{@path}") do
127
159
  file_list.update
128
160
  send_refresh_to_plugins
129
161
  end
130
162
  end
131
-
163
+
132
164
  def refresh_modified_file(path)
133
165
  file_list.update(path)
134
166
  @tree.refresh
135
167
  send_refresh_to_plugins
136
168
  end
137
-
169
+
138
170
  def all_files
139
171
  file_list.all_files
140
172
  end
141
-
173
+
142
174
  def send_refresh_to_plugins
143
175
  Redcar.plugin_manager.objects_implementing(:project_refresh_task_type).each do |object|
144
176
  Redcar.app.task_queue.submit(object.project_refresh_task_type.new(self))
145
177
  end
146
178
  end
147
-
179
+
148
180
  def lost_application_focus
149
181
  @lost_application_focus = true
150
182
  end
151
-
183
+
152
184
  def gained_focus
153
185
  refresh
154
186
  @lost_application_focus = nil
155
187
  end
156
-
188
+
157
189
  def config_dir
158
190
  dir = File.join(path, ".redcar")
159
191
  FileUtils.mkdir_p(dir)
160
192
  dir
161
193
  end
162
-
194
+
163
195
  def home_dir
164
196
  @path
165
197
  end
166
-
198
+
167
199
  def config_files(glob)
168
200
  file_glob = File.join("{#{config_dir},#{Redcar.user_dir}}", glob)
169
201
  Dir[file_glob]