redcar 0.2.9dev → 0.3.0dev

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 (51) hide show
  1. data/ROADMAP.md +2 -2
  2. data/Rakefile +4 -4
  3. data/lib/redcar/boot.rb +3 -0
  4. data/lib/redcar/install.rb +3 -3
  5. data/lib/redcar/runner.rb +1 -1
  6. data/lib/redcar/usage.rb +5 -0
  7. data/plugins/application/features/step_definitions/tree_steps.rb +6 -0
  8. data/plugins/application/features/support/env.rb +59 -1
  9. data/plugins/application/icons/darwin-file.png +0 -0
  10. data/plugins/application/icons/darwin-folder.png +0 -0
  11. data/plugins/application/lib/application.rb +4 -0
  12. data/plugins/application/lib/application/command/executor.rb +3 -1
  13. data/plugins/application/lib/application/dialog.rb +5 -0
  14. data/plugins/application/lib/application/treebook.rb +30 -0
  15. data/plugins/application/lib/application/window.rb +3 -3
  16. data/plugins/application/spec/application/treebook_spec.rb +27 -0
  17. data/plugins/application/spec/application/window_spec.rb +2 -2
  18. data/plugins/application_swt/lib/application_swt.rb +1 -0
  19. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +12 -0
  20. data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +4 -7
  21. data/plugins/application_swt/lib/application_swt/treebook.rb +33 -0
  22. data/plugins/application_swt/lib/application_swt/window.rb +63 -12
  23. data/plugins/auto_indenter/lib/auto_indenter.rb +12 -0
  24. data/plugins/auto_indenter/lib/auto_indenter/document_controller.rb +27 -0
  25. data/plugins/auto_indenter/plugin.yaml +12 -0
  26. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +1 -1
  27. data/plugins/edit_view/features/step_definitions/tab_steps.rb +11 -0
  28. data/plugins/edit_view/features/step_definitions/window_steps.rb +2 -2
  29. data/plugins/edit_view/features/support/env.rb +4 -26
  30. data/plugins/edit_view/lib/edit_view.rb +2 -1
  31. data/plugins/edit_view/lib/edit_view/document.rb +46 -14
  32. data/plugins/edit_view/lib/edit_view/document/controller.rb +30 -0
  33. data/plugins/edit_view/lib/edit_view/{mirror.rb → document/mirror.rb} +1 -1
  34. data/plugins/edit_view_swt/lib/edit_view_swt.rb +22 -0
  35. data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +29 -0
  36. data/plugins/project/features/open_directory_tree.feature +17 -0
  37. data/plugins/project/features/step_definitions/directory_steps.rb +4 -0
  38. data/plugins/project/lib/project.rb +51 -0
  39. data/plugins/project/lib/project/dir_controller.rb +14 -0
  40. data/plugins/project/lib/project/dir_mirror.rb +18 -3
  41. data/plugins/project/lib/project/file_mirror.rb +1 -1
  42. data/plugins/redcar/redcar.rb +3 -0
  43. data/plugins/repl/lib/repl/internal_mirror.rb +1 -1
  44. data/plugins/tree/lib/tree.rb +17 -0
  45. data/plugins/tree/lib/tree/controller.rb +12 -0
  46. data/plugins/{tree_view/lib/tree_view → tree/lib/tree}/mirror.rb +1 -1
  47. data/plugins/{tree_view → tree}/plugin.yaml +4 -4
  48. data/plugins/{tree_view → tree}/spec/spec_helper.rb +0 -0
  49. data/plugins/tree_view_swt/lib/tree_view_swt.rb +122 -0
  50. metadata +21 -7
  51. data/plugins/tree_view/lib/tree_view.rb +0 -7
@@ -2,7 +2,7 @@
2
2
  module Redcar
3
3
  class Project
4
4
  class DirMirror
5
- include Redcar::TreeView::Mirror
5
+ include Redcar::Tree::Mirror
6
6
 
7
7
  # @param [String] a path to a directory
8
8
  def initialize(path)
@@ -16,10 +16,15 @@ module Redcar
16
16
  end
17
17
 
18
18
  # Have the toplevel nodes changed?
19
+ #
20
+ # @return [Boolean]
19
21
  def changed?
20
22
  @changed
21
23
  end
22
24
 
25
+ # Get the top-level nodes
26
+ #
27
+ # @return [Array<Node>]
23
28
  def top
24
29
  @changed = false
25
30
  Node.create_all_from_path(@path)
@@ -27,10 +32,12 @@ module Redcar
27
32
 
28
33
  class Node
29
34
  def self.create_all_from_path(path)
30
- Dir[path + "/*"].map {|fn| Node.new(fn)}
35
+ Dir[path + "/*"].sort_by {|fn| fn.downcase }.map {|fn| Node.new(fn)}
31
36
  end
32
37
 
33
- include Redcar::TreeView::Mirror::NodeMirror
38
+ include Redcar::Tree::Mirror::NodeMirror
39
+
40
+ attr_reader :path
34
41
 
35
42
  def initialize(path)
36
43
  @path = path
@@ -40,6 +47,14 @@ module Redcar
40
47
  File.basename(@path)
41
48
  end
42
49
 
50
+ def icon
51
+ if File.file?(@path)
52
+ :file
53
+ elsif File.directory?(@path)
54
+ :directory
55
+ end
56
+ end
57
+
43
58
  def leaf?
44
59
  File.file?(@path)
45
60
  end
@@ -8,7 +8,7 @@ module Redcar
8
8
  # loaded in Redcar. EditView contains a Document which contains a Mirror
9
9
  # which reflects a file.
10
10
  class FileMirror
11
- include Redcar::EditView::Mirror
11
+ include Redcar::Document::Mirror
12
12
 
13
13
  # @param [String] a path to a file
14
14
  def initialize(path)
@@ -11,6 +11,7 @@ module Redcar
11
11
  tab = win.new_tab(Redcar::EditTab)
12
12
  tab.title = "untitled"
13
13
  tab.focus
14
+ tab
14
15
  end
15
16
  end
16
17
 
@@ -132,6 +133,7 @@ module Redcar
132
133
  item "New Notebook", NewNotebookCommand
133
134
  item "New Window", NewWindowCommand
134
135
  item "Open", Project::FileOpenCommand
136
+ item "Open Directory", Project::DirectoryOpenCommand
135
137
  separator
136
138
  item "Save", Project::FileSaveCommand
137
139
  item "Save As", Project::FileSaveAsCommand
@@ -139,6 +141,7 @@ module Redcar
139
141
  item "Close Tab", CloseTabCommand
140
142
  item "Close Notebook", CloseNotebookCommand
141
143
  item "Close Window", CloseWindowCommand
144
+ item "Close Directory", Project::DirectoryCloseCommand
142
145
  end
143
146
  sub_menu "Debug" do
144
147
  item "Print Command History", PrintHistoryCommand
@@ -2,7 +2,7 @@
2
2
  module Redcar
3
3
  class REPL
4
4
  class InternalMirror
5
- include Redcar::EditView::Mirror
5
+ include Redcar::Document::Mirror
6
6
 
7
7
  attr_reader :history, :results
8
8
 
@@ -0,0 +1,17 @@
1
+
2
+ require 'tree/controller'
3
+ require 'tree/mirror'
4
+
5
+ module Redcar
6
+ class Tree
7
+ include Redcar::Model
8
+
9
+ attr_reader :tree_mirror, :tree_controller
10
+
11
+ def initialize(tree_mirror, tree_controller=nil)
12
+ @tree_mirror = tree_mirror
13
+ @tree_controller = tree_controller
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,12 @@
1
+
2
+ module Redcar
3
+ class Tree
4
+ # Abstract interface. The Controller's methods are called when the Tree's
5
+ # rows are activated.
6
+ module Controller
7
+ def activated(node)
8
+ raise "not implemented"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Redcar
3
- class TreeView
3
+ class Tree
4
4
  # Abstract interface. A Mirror allows an TreeView contents to reflect
5
5
  # some other resource, for example a directory tree on disk.
6
6
  # They have methods for loading the contents from the resource.
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:FreeBASE::PluginConfiguration
2
- name: tree_view
3
- description: Tree view is the tree view widget
2
+ name: tree
3
+ description: Trees are shown in the sidepane
4
4
  version: 1.0
5
5
  author: Daniel Lucraft
6
6
  autoload: true
7
- require_path: tree_view/lib/tree_view.rb
8
- startup_module: Redcar::TreeView
7
+ require_path: tree/lib/tree.rb
8
+ startup_module: Redcar::Tree
9
9
  load_dependencies:
10
10
  core: "*"
11
11
  application: "*"
@@ -1,5 +1,127 @@
1
1
 
2
2
  module Redcar
3
3
  class TreeViewSWT
4
+
5
+ def initialize(composite, model)
6
+ @composite, @model = composite, model
7
+ @viewer = JFace::Viewers::TreeViewer.new(@composite, Swt::SWT::VIRTUAL)
8
+ @viewer.set_content_provider(TreeMirrorContentProvider.new)
9
+ @viewer.set_input(@model.tree_mirror)
10
+ @viewer.set_label_provider(TreeMirrorLabelProvider.new)
11
+
12
+ if @model.tree_controller
13
+ @viewer.add_tree_listener(@viewer.getControl, TreeListener.new)
14
+ @viewer.add_open_listener(OpenListener.new(@model.tree_controller))
15
+ end
16
+ end
17
+
18
+ def control
19
+ @viewer.getControl
20
+ end
21
+
22
+ def close
23
+ @viewer.getControl.dispose
24
+ end
25
+
26
+ class TreeListener
27
+ def tree_collapsed(e)
28
+ p [:collapsed, e]
29
+ end
30
+
31
+ def tree_expanded(e)
32
+ p [:expanded, e]
33
+ end
34
+ end
35
+
36
+ class SelectionListener
37
+ def widget_default_selected(e)
38
+ p [:def_selected, e]
39
+ end
40
+
41
+ def widget_selected(e)
42
+ p [:selected, e]
43
+ end
44
+ end
45
+
46
+ class DoubleClickListener
47
+ def double_click(e)
48
+ p [:double_click, e]
49
+ end
50
+ end
51
+
52
+ class OpenListener
53
+ def initialize(controller)
54
+ @controller = controller
55
+ end
56
+
57
+ def open(e)
58
+ @controller.activated(e.getSelection.toArray.to_a.first)
59
+ end
60
+ end
61
+
62
+ class TreeMirrorContentProvider
63
+ include JFace::Viewers::ITreeContentProvider
64
+
65
+ def input_changed(viewer, _, tree_mirror)
66
+ @viewer, @tree_mirror = viewer, tree_mirror
67
+ end
68
+
69
+ def get_elements(tree_mirror)
70
+ tree_mirror.top.to_java
71
+ end
72
+
73
+ def has_children(tree_node)
74
+ tree_node.children.any?
75
+ end
76
+
77
+ def get_children(tree_node)
78
+ tree_node.children.to_java
79
+ end
80
+
81
+ def dispose
82
+ end
83
+ end
84
+
85
+ class TreeMirrorLabelProvider
86
+ include JFace::Viewers::ILabelProvider
87
+
88
+ def add_listener(*_)
89
+ end
90
+
91
+ def remove_listener(*_)
92
+ end
93
+
94
+ def get_text(tree_node)
95
+ tree_node.text
96
+ end
97
+
98
+ def get_image(tree_node)
99
+ case tree_node.icon
100
+ when :directory
101
+ dir_image
102
+ when :file
103
+ file_image
104
+ end
105
+ end
106
+
107
+ def dispose
108
+ end
109
+
110
+ private
111
+
112
+ def dir_image
113
+ @dir_image ||= begin
114
+ path = File.join(Redcar.root, %w(plugins application icons darwin-folder.png))
115
+ Swt::Graphics::Image.new(ApplicationSWT.display, path)
116
+ end
117
+ end
118
+
119
+ def file_image
120
+ @file_image ||= begin
121
+ path = File.join(Redcar.root, %w(plugins application icons darwin-file.png))
122
+ Swt::Graphics::Image.new(ApplicationSWT.display, path)
123
+ end
124
+ end
125
+ end
4
126
  end
5
127
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redcar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9dev
4
+ version: 0.3.0dev
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lucraft
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-17 00:00:00 +00:00
12
+ date: 2009-12-25 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -155,8 +155,11 @@ files:
155
155
  - plugins/application/features/main_window.feature
156
156
  - plugins/application/features/step_definitions/dialog_steps.rb
157
157
  - plugins/application/features/step_definitions/menu_steps.rb
158
+ - plugins/application/features/step_definitions/tree_steps.rb
158
159
  - plugins/application/features/step_definitions/window_steps.rb
159
160
  - plugins/application/features/support/env.rb
161
+ - plugins/application/icons/darwin-file.png
162
+ - plugins/application/icons/darwin-folder.png
160
163
  - plugins/application/lib/application.rb
161
164
  - plugins/application/lib/application/command.rb
162
165
  - plugins/application/lib/application/dialog.rb
@@ -165,6 +168,7 @@ files:
165
168
  - plugins/application/lib/application/sensitive.rb
166
169
  - plugins/application/lib/application/sensitivity.rb
167
170
  - plugins/application/lib/application/tab.rb
171
+ - plugins/application/lib/application/treebook.rb
168
172
  - plugins/application/lib/application/window.rb
169
173
  - plugins/application/lib/application/assets/file.png
170
174
  - plugins/application/lib/application/command/executor.rb
@@ -178,6 +182,7 @@ files:
178
182
  - plugins/application/spec/application/menu_spec.rb
179
183
  - plugins/application/spec/application/notebook_spec.rb
180
184
  - plugins/application/spec/application/sensitive_spec.rb
185
+ - plugins/application/spec/application/treebook_spec.rb
181
186
  - plugins/application/spec/application/window_spec.rb
182
187
  - plugins/application/spec/application/command/executor_spec.rb
183
188
  - plugins/application/spec/application/command/history_spec.rb
@@ -196,6 +201,7 @@ files:
196
201
  - plugins/application_swt/lib/application_swt/notebook.rb
197
202
  - plugins/application_swt/lib/application_swt/swt_wrapper.rb
198
203
  - plugins/application_swt/lib/application_swt/tab.rb
204
+ - plugins/application_swt/lib/application_swt/treebook.rb
199
205
  - plugins/application_swt/lib/application_swt/window.rb
200
206
  - plugins/application_swt/lib/application_swt/menu/binding_translator.rb
201
207
  - plugins/application_swt/lib/application_swt/notebook/drag_and_drop_listener.rb
@@ -207,6 +213,9 @@ files:
207
213
  - plugins/application_swt/vendor/swt/osx/dummy
208
214
  - plugins/application_swt/vendor/swt/osx64/dummy
209
215
  - plugins/application_swt/vendor/swt/win32/dummy
216
+ - plugins/auto_indenter/plugin.yaml
217
+ - plugins/auto_indenter/lib/auto_indenter.rb
218
+ - plugins/auto_indenter/lib/auto_indenter/document_controller.rb
210
219
  - plugins/core/plugin.yaml
211
220
  - plugins/core/lib/core.rb
212
221
  - plugins/core/lib/core/controller.rb
@@ -231,7 +240,8 @@ files:
231
240
  - plugins/edit_view/lib/edit_view/command.rb
232
241
  - plugins/edit_view/lib/edit_view/document.rb
233
242
  - plugins/edit_view/lib/edit_view/edit_tab.rb
234
- - plugins/edit_view/lib/edit_view/mirror.rb
243
+ - plugins/edit_view/lib/edit_view/document/controller.rb
244
+ - plugins/edit_view/lib/edit_view/document/mirror.rb
235
245
  - plugins/edit_view/spec/spec_helper.rb
236
246
  - plugins/edit_view/spec/edit_view/document_spec.rb
237
247
  - plugins/edit_view_swt/plugin.yaml
@@ -242,10 +252,13 @@ files:
242
252
  - plugins/edit_view_swt/vendor/java-mateview.rb
243
253
  - plugins/project/plugin.yaml
244
254
  - plugins/project/features/open_and_save_files.feature
255
+ - plugins/project/features/open_directory_tree.feature
245
256
  - plugins/project/features/fixtures/winter.txt
257
+ - plugins/project/features/step_definitions/directory_steps.rb
246
258
  - plugins/project/features/step_definitions/file_steps.rb
247
259
  - plugins/project/features/support/env.rb
248
260
  - plugins/project/lib/project.rb
261
+ - plugins/project/lib/project/dir_controller.rb
249
262
  - plugins/project/lib/project/dir_mirror.rb
250
263
  - plugins/project/lib/project/file_mirror.rb
251
264
  - plugins/project/spec/spec_helper.rb
@@ -258,10 +271,11 @@ files:
258
271
  - plugins/repl/lib/repl/internal_mirror.rb
259
272
  - plugins/repl/spec/spec_helper.rb
260
273
  - plugins/repl/spec/repl/internal_mirror_spec.rb
261
- - plugins/tree_view/plugin.yaml
262
- - plugins/tree_view/lib/tree_view.rb
263
- - plugins/tree_view/lib/tree_view/mirror.rb
264
- - plugins/tree_view/spec/spec_helper.rb
274
+ - plugins/tree/plugin.yaml
275
+ - plugins/tree/lib/tree.rb
276
+ - plugins/tree/lib/tree/controller.rb
277
+ - plugins/tree/lib/tree/mirror.rb
278
+ - plugins/tree/spec/spec_helper.rb
265
279
  - plugins/tree_view_swt/plugin.yaml
266
280
  - plugins/tree_view_swt/lib/tree_view_swt.rb
267
281
  - textmate/Bundles/C.tmbundle/Syntaxes/C.plist
@@ -1,7 +0,0 @@
1
-
2
- require 'tree_view/mirror'
3
-
4
- module Redcar
5
- class TreeView
6
- end
7
- end