redcar-dev 0.12.27dev → 0.13.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 (42) hide show
  1. data/CHANGES +10 -1
  2. data/lib/redcar.rb +2 -2
  3. data/plugins/application/lib/application.rb +2 -2
  4. data/plugins/application/lib/application/dialog.rb +1 -1
  5. data/plugins/application/lib/application/dialogs/filter_list_dialog.rb +13 -5
  6. data/plugins/application/lib/application/global_state.rb +21 -0
  7. data/plugins/application/lib/application/menu/item.rb +16 -7
  8. data/plugins/application/lib/application/updates.rb +20 -3
  9. data/plugins/application/spec/application/updates_spec.rb +53 -0
  10. data/plugins/application_swt/lib/application_swt.rb +1 -1
  11. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +35 -10
  12. data/plugins/application_swt/lib/application_swt/menu.rb +31 -5
  13. data/plugins/declarations/lib/declarations.rb +31 -65
  14. data/plugins/declarations/lib/declarations/commands.rb +147 -0
  15. data/plugins/declarations/lib/declarations/file.rb +1 -1
  16. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/javascript.js +0 -0
  17. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/nothing_to_see.rb +0 -0
  18. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/one_lonely_class.rb +0 -0
  19. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/similar_names.rb +0 -0
  20. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/something_fancy.rb +0 -0
  21. data/plugins/{outline_view → declarations}/spec/fixtures/some_project/trailing_space.rb +0 -0
  22. data/plugins/edit_view/lib/edit_view.rb +35 -2
  23. data/plugins/edit_view/lib/edit_view/commands/change_language_command.rb +31 -0
  24. data/plugins/edit_view/lib/edit_view/commands/language_settings_commands.rb +45 -0
  25. data/plugins/edit_view/lib/edit_view/document/command.rb +1 -1
  26. data/plugins/project/lib/project/find_file_dialog.rb +20 -18
  27. data/plugins/project/lib/project/manager.rb +5 -3
  28. data/plugins/redcar/plugin.rb +1 -2
  29. data/plugins/redcar/redcar.rb +34 -42
  30. data/plugins/scm/lib/scm.rb +1 -1
  31. data/plugins/strip_trailing_spaces/lib/strip_trailing_spaces.rb +2 -2
  32. data/plugins/syntax_check/lib/syntax_check.rb +2 -2
  33. metadata +946 -956
  34. data/plugins/edit_view/lib/edit_view/info_speedbar.rb +0 -98
  35. data/plugins/outline_view/features/outline_view.feature +0 -79
  36. data/plugins/outline_view/features/project_outline.feature +0 -23
  37. data/plugins/outline_view/features/step_definitions/outline_steps.rb +0 -61
  38. data/plugins/outline_view/lib/outline_view.rb +0 -97
  39. data/plugins/outline_view/lib/outline_view/commands.rb +0 -19
  40. data/plugins/outline_view/plugin.rb +0 -10
  41. data/plugins/outline_view_swt/lib/outline_view_swt.rb +0 -79
  42. data/plugins/outline_view_swt/plugin.rb +0 -7
data/CHANGES CHANGED
@@ -1,6 +1,13 @@
1
- Version 0.12 (TBA)
1
+ Version 0.13 (TBA)
2
2
  ==================
3
3
 
4
+ * Move all language settings options into the Edit menu, for easier discoverability.(Dan Lucraft)
5
+ * Move the change tab language command into the Edit menu, and make it a filter list. (Dan Lucraft)
6
+
7
+
8
+ Version 0.12 (7th January 2012)
9
+ ===============================
10
+
4
11
  * Features run all the way through again, and use Swtbot in places to
5
12
  allow us to simulate events more accurately (Helpful for macros) (Dan Lucraft)
6
13
  * Added --no-splash option (Dan Lucraft)
@@ -21,9 +28,11 @@ Version 0.12 (TBA)
21
28
  * Added option to color tree background color via ApplicationSWT preferences (Delisa Mason)
22
29
  * Project tree has colourful icons (Delisa Mason)
23
30
  * Uses gems to install everything (Dan Lucraft)
31
+ * Uses Bundler to manage dependencies in development (Dan Lucraft)
24
32
  * Wildcards permitted in project search (Delisa Mason)
25
33
  * Installation entirely through Rubygems (Dan Lucraft)
26
34
  * Rad new icon (Delisa Mason)
35
+ * Checks for updates and displays if there is a new version in the Help menu (Dan Lucraft)
27
36
 
28
37
  Version 0.11 (23 March 2011)
29
38
  ============================
@@ -68,9 +68,9 @@ end
68
68
  #
69
69
  # and so on.
70
70
  module Redcar
71
- VERSION = '0.12.27dev' # also change in the gemspec!
71
+ VERSION = '0.13.0dev' # also change in the gemspec!
72
72
  VERSION_MAJOR = 0
73
- VERSION_MINOR = 12
73
+ VERSION_MINOR = 13
74
74
  VERSION_RELEASE = 0
75
75
 
76
76
  ENVIRONMENTS = [:user, :debug, :test]
@@ -12,6 +12,7 @@ require 'application/dialog'
12
12
  require 'application/dialogs/filter_list_dialog'
13
13
  require 'application/dialogs/modeless_list_dialog'
14
14
  require 'application/event_spewer'
15
+ require 'application/global_state'
15
16
  require 'application/keymap'
16
17
  require 'application/keymap/builder'
17
18
  require 'application/toolbar'
@@ -152,7 +153,6 @@ module Redcar
152
153
 
153
154
  # Create a new Application::Window, and the controller for it.
154
155
  def new_window(show=true)
155
- s = Time.now
156
156
  new_window = Window.new
157
157
  windows << new_window
158
158
  notify_listeners(:new_window, new_window)
@@ -198,7 +198,7 @@ module Redcar
198
198
  @storage ||= begin
199
199
  storage = Plugin::Storage.new('application_plugin')
200
200
  storage.set_default('stay_resident_after_last_window_closed', false)
201
- storage.set_default('show_toolbar', true)
201
+ storage.set_default('show_toolbar', Redcar.platform != :osx)
202
202
  storage.set_default('instance_id', java.util.UUID.randomUUID.to_s)
203
203
  storage.set_default('should_check_for_updates', true)
204
204
  storage
@@ -84,7 +84,7 @@ module Redcar
84
84
  #
85
85
  # The return value is a hash containing :button and :value.
86
86
  def self.input(title, message, initial_value="", &validator)
87
- in_dialog { Redcar.gui.dialog_adapter.input(title, message, initial_value, &validator) }
87
+ in_dialog { Redcar.gui.dialog_adapter.input(title.to_s, message.to_s, initial_value.to_s, &validator) }
88
88
  end
89
89
 
90
90
  # Show a dialog containing a password entry box to the user, and blocks
@@ -20,10 +20,18 @@ module Redcar
20
20
  notify_listeners(:close)
21
21
  end
22
22
 
23
- # Called by the controller when the user changes the filter.
23
+ # Called by the controller when the user changes the filter.
24
+ #
25
+ # Should return either a list of strings, or a list of hashes, which must have at least
26
+ # the key :name set, and may also have the key :image.
27
+ #
28
+ # E.g. it returns ["feed.rb", "application_controller.rb"]
29
+ # or it returns [{:name => "feed.rb"}, {:name => "application_controller.rb"}]
30
+ #
31
+ # The methods selected and moved_to will be called with items from this list.
24
32
  #
25
33
  # @param [String] the filter entered by the user
26
- # @return [Array<String>] the new list to display
34
+ # @return [Array<String> or Array<Hash>] the new list to display
27
35
  def update_list(filter)
28
36
  if filter == ""
29
37
  %w(foo bar baz qux quux corge)
@@ -36,9 +44,9 @@ module Redcar
36
44
 
37
45
  # Called by the controller when the user selects a row in the list.
38
46
  #
39
- # @param [String] the list row text selected by the user
47
+ # @param [String or Hash] the item selected by the user
40
48
  # @param [Integer] the index of the row in the list selected by the user
41
- def selected(text, ix)
49
+ def selected(item, ix)
42
50
  puts "Hooray! You selected #{text} at index #{ix}"
43
51
  end
44
52
 
@@ -46,7 +54,7 @@ module Redcar
46
54
  #
47
55
  # @param [String] the list row text that is now highlighted
48
56
  # @param [Integer] the index of the row that is now highlighted
49
- def moved_to(text, ix)
57
+ def moved_to(item, ix)
50
58
  # Override with the code you wish you had
51
59
  end
52
60
 
@@ -0,0 +1,21 @@
1
+ module Redcar
2
+ class Application
3
+ class GlobalState
4
+ def app
5
+ Redcar.app
6
+ end
7
+
8
+ def win
9
+ app and app.focussed_window
10
+ end
11
+
12
+ def project
13
+ win and Project.in_window(win)
14
+ end
15
+
16
+ def tab
17
+ win and win.focussed_notebook_tab
18
+ end
19
+ end
20
+ end
21
+ end
@@ -12,7 +12,7 @@ module Redcar
12
12
  end
13
13
  end
14
14
 
15
- attr_reader :command, :priority, :value, :type, :active
15
+ attr_reader :command, :priority, :value, :type
16
16
 
17
17
  # Create a new Item, with the given text to display in the menu, and
18
18
  # either:
@@ -26,10 +26,9 @@ module Redcar
26
26
  @priority = options[:priority]
27
27
  @value = options[:value]
28
28
  @type = options[:type]
29
- @active = options[:active] ? true : false
30
- # This branch is for compatibility with old code. Please use :command
31
- # option in new code
32
- # FIXME: Should this be removed at some point?
29
+ if [:check, :radio].include?(@type)
30
+ @checked = options[:checked]
31
+ end
33
32
  else
34
33
  @command = options || block
35
34
  end
@@ -55,11 +54,13 @@ module Redcar
55
54
  end
56
55
 
57
56
  def text
58
- @text.is_a?(Proc) ? @text.call : @text
57
+ @text.respond_to?(:call) ?
58
+ Redcar::Application::GlobalState.new.instance_eval(&@text) :
59
+ @text
59
60
  end
60
61
 
61
62
  def lazy_text?
62
- @text.is_a?(Proc)
63
+ @text.respond_to?(:call)
63
64
  end
64
65
 
65
66
  def merge(other)
@@ -74,6 +75,14 @@ module Redcar
74
75
  def is_unique?
75
76
  false
76
77
  end
78
+
79
+ def checked?
80
+ @checked and (
81
+ @checked.respond_to?(:call) ?
82
+ Redcar::Application::GlobalState.new.instance_eval(&@checked) :
83
+ @checked
84
+ )
85
+ end
77
86
  end
78
87
  end
79
88
  end
@@ -31,12 +31,29 @@ module Redcar
31
31
  end
32
32
 
33
33
  def self.latest_version
34
- @latest_version ||= Net::HTTP.get(URI.parse("http://s3.amazonaws.com/redcar2/current_version.txt?instance_id=#{Application.instance_id}")).strip
34
+ @latest_version ||= Net::HTTP.get(URI.parse(latest_version_url)).strip
35
+ end
36
+
37
+ def self.latest_version_url
38
+ "http://s3.amazonaws.com/redcar2/current_version.txt?instance_id=#{Application.instance_id}&version=#{Redcar::VERSION}"
35
39
  end
36
40
 
37
41
  def self.newer_version?
38
- latest_version_bits = latest_version.split(".").map(&:to_i)
39
- [latest_version_bits, [Redcar::VERSION_MAJOR, Redcar::VERSION_MINOR, Redcar::VERSION_RELEASE]].sort.last == latest_version_bits
42
+ latest_version_bits = latest_version.chomp.split(".").map(&:to_i)
43
+ newer_than?(latest_version_bits, [Redcar::VERSION_MAJOR, Redcar::VERSION_MINOR, Redcar::VERSION_RELEASE])
44
+ end
45
+
46
+ def self.newer_than?(new_bits, old_bits)
47
+ # if they are not the same length, pad with 0's to make comparison
48
+ # valid. E.g. 0.10.0 == 0.10
49
+ if new_bits.length > old_bits.length
50
+ old_bits += [0]*(new_bits.length - old_bits.length)
51
+ elsif old_bits.length > new_bits.length
52
+ new_bits += [0]*(old_bits.length - new_bits.length)
53
+ end
54
+
55
+ return false if new_bits == old_bits
56
+ [new_bits, old_bits].sort.last == new_bits
40
57
  end
41
58
 
42
59
  end
@@ -0,0 +1,53 @@
1
+
2
+ require "spec_helper"
3
+
4
+ describe Redcar::Application::Updates do
5
+
6
+ describe "comparing versions logic" do
7
+
8
+ it "0.10 = 0.10" do
9
+ Redcar::Application::Updates.newer_than?([0, 10], [0, 10]).should be_false
10
+ end
11
+
12
+ it "0.10.0 = 0.10" do
13
+ Redcar::Application::Updates.newer_than?([0, 10, 0], [0, 10]).should be_false
14
+ end
15
+
16
+ it "0.10 = 0.10.0" do
17
+ Redcar::Application::Updates.newer_than?([0, 10], [0, 10, 0]).should be_false
18
+ end
19
+
20
+ it "0.10.1 > 0.10" do
21
+ Redcar::Application::Updates.newer_than?([0, 10, 1], [0, 10]).should be_true
22
+ end
23
+
24
+ it "0.11 > 0.10" do
25
+ Redcar::Application::Updates.newer_than?([0, 11], [0, 10]).should be_true
26
+ end
27
+
28
+ it "0.11.1 > 0.10" do
29
+ Redcar::Application::Updates.newer_than?([0, 11, 1], [0, 10]).should be_true
30
+ end
31
+
32
+ it "0.11 > 0.10.1" do
33
+ Redcar::Application::Updates.newer_than?([0, 11], [0, 10, 1]).should be_true
34
+ end
35
+
36
+ it "0.11.1 > 0.10.1" do
37
+ Redcar::Application::Updates.newer_than?([0, 11, 1], [0, 10, 1]).should be_true
38
+ end
39
+
40
+ it "0.9 < 0.10" do
41
+ Redcar::Application::Updates.newer_than?([0, 9], [0, 10]).should be_false
42
+ end
43
+
44
+ it "0.9.1 < 0.10" do
45
+ Redcar::Application::Updates.newer_than?([0, 9, 1], [0, 10]).should be_false
46
+ end
47
+
48
+ it "0.9 < 0.10.1" do
49
+ Redcar::Application::Updates.newer_than?([0, 9], [0, 10, 1]).should be_false
50
+ end
51
+
52
+ end
53
+ end
@@ -13,8 +13,8 @@ require "application_swt/dialogs/modeless_dialog"
13
13
  require "application_swt/dialogs/modeless_html_dialog"
14
14
  require "application_swt/dialogs/modeless_list_dialog_controller"
15
15
  require "application_swt/gradient"
16
- require "application_swt/html_tab"
17
16
  require "application_swt/icon"
17
+ require "application_swt/html_tab"
18
18
  require "application_swt/listener_helpers"
19
19
  require "application_swt/menu"
20
20
  require "application_swt/menu/binding_translator"
@@ -14,20 +14,33 @@ module Redcar
14
14
  attr_accessor :controller
15
15
 
16
16
  def createDialogArea(parent)
17
+ # composite = Swt::Widgets::Composite.new(parent, Swt::SWT::NONE)
18
+ # layout = Swt::Layout::RowLayout.new(Swt::SWT::VERTICAL)
19
+ # composite.setLayout(layout)
20
+ #
21
+ # @text = Swt::Widgets::Text.new(composite, Swt::SWT::SINGLE | Swt::SWT::LEFT | Swt::SWT::ICON_CANCEL | Swt::SWT::SEARCH)
22
+ # @text.set_layout_data(Swt::Layout::RowData.new(400, 20))
23
+ # @list = Swt::Widgets::List.new(composite, Swt::SWT::V_SCROLL | Swt::SWT::H_SCROLL | Swt::SWT::SINGLE)
24
+ # @list.set_layout_data(Swt::Layout::RowData.new(400, 200))
25
+ # controller.attach_listeners
26
+ # controller.update_list_sync
27
+ # get_shell.add_shell_listener(ShellListener.new(controller))
28
+ # ApplicationSWT.register_shell(get_shell)
29
+ # ApplicationSWT.register_dialog(get_shell, self)
30
+ #
31
+ # @list.set_selection(0)
17
32
  composite = Swt::Widgets::Composite.new(parent, Swt::SWT::NONE)
18
33
  layout = Swt::Layout::RowLayout.new(Swt::SWT::VERTICAL)
19
34
  composite.setLayout(layout)
20
-
21
35
  @text = Swt::Widgets::Text.new(composite, Swt::SWT::SINGLE | Swt::SWT::LEFT | Swt::SWT::ICON_CANCEL | Swt::SWT::SEARCH)
22
36
  @text.set_layout_data(Swt::Layout::RowData.new(400, 20))
23
- @list = Swt::Widgets::List.new(composite, Swt::SWT::V_SCROLL | Swt::SWT::H_SCROLL | Swt::SWT::SINGLE)
37
+ @list = Swt::Widgets::Table.new(composite, Swt::SWT::V_SCROLL | Swt::SWT::H_SCROLL | Swt::SWT::MULTI)
24
38
  @list.set_layout_data(Swt::Layout::RowData.new(400, 200))
25
39
  controller.attach_listeners
26
40
  controller.update_list_sync
27
41
  get_shell.add_shell_listener(ShellListener.new(controller))
28
- ApplicationSWT.register_shell(get_shell)
29
- ApplicationSWT.register_dialog(get_shell, self)
30
-
42
+ Redcar::ApplicationSWT.register_shell(get_shell)
43
+ Redcar::ApplicationSWT.register_dialog(get_shell, self)
31
44
  @list.set_selection(0)
32
45
  end
33
46
  end
@@ -167,7 +180,8 @@ module Redcar
167
180
 
168
181
  def widget_selected
169
182
  if @model.step?
170
- @model.moved_to(@dialog.list.get_selection.first, @dialog.list.get_selection_index)
183
+ ix = @dialog.list.get_selection_index
184
+ @model.moved_to(@list[ix], ix)
171
185
  end
172
186
  end
173
187
 
@@ -185,7 +199,8 @@ module Redcar
185
199
 
186
200
  def selected
187
201
  wait_for_search if select_closest_match?
188
- @model.selected(@dialog.list.get_selection.first, @dialog.list.get_selection_index)
202
+ ix = @dialog.list.get_selection_index
203
+ @model.selected(@list[ix], ix)
189
204
  end
190
205
 
191
206
  def key_pressed(key_event)
@@ -221,10 +236,20 @@ module Redcar
221
236
  end
222
237
 
223
238
  def populate_list(contents)
239
+ @list = contents
224
240
  if @dialog
225
- @dialog.list.removeAll
226
- contents.each do |text|
227
- @dialog.list.add(text)
241
+ @dialog.list.remove_all
242
+ contents.each do |props|
243
+ if props.is_a?(String)
244
+ props = {:name => props}
245
+ end
246
+ props = {:name => ""}.merge(props)
247
+ item = Swt::Widgets::TableItem.new(@dialog.list, Swt::SWT::NONE)
248
+ item.text = props[:name]
249
+ image = ApplicationSWT::Icon.swt_image(props[:icon]) if props[:icon]
250
+ if image
251
+ item.image = image
252
+ end
228
253
  end
229
254
  end
230
255
  end
@@ -31,11 +31,13 @@ module Redcar
31
31
  @keymap = keymap
32
32
  @menu_bar = Swt::Widgets::Menu.new(window.shell, type)
33
33
  @menu_bar.set_visible(false)
34
+
34
35
  return unless menu_model
35
36
  @handlers = []
36
37
  @use_numbers = options[:numbers]
37
38
  @number = 1
38
- add_entries_to_menu(@menu_bar, menu_model)
39
+
40
+ add_entries_to_menu(@menu_bar, nil, menu_model)
39
41
  #puts "ApplicationSWT::Menu initialize took #{Time.now - s}s"
40
42
  end
41
43
 
@@ -59,7 +61,26 @@ module Redcar
59
61
  @use_numbers
60
62
  end
61
63
 
62
- def add_entries_to_menu(menu, menu_model)
64
+ class MenuListener
65
+ attr_reader :items
66
+
67
+ def initialize
68
+ @items = []
69
+ end
70
+
71
+ def menu_shown(e)
72
+ items.each do |item, entry|
73
+ if entry.type == :check
74
+ item.setSelection(entry.checked?)
75
+ end
76
+ end
77
+ end
78
+
79
+ def menu_hidden(e)
80
+ end
81
+ end
82
+
83
+ def add_entries_to_menu(menu, menu_listener, menu_model)
63
84
  menu_model.each do |entry|
64
85
  if entry.is_a?(Redcar::Menu::LazyMenu)
65
86
  menu_header = Swt::Widgets::MenuItem.new(menu, Swt::SWT::CASCADE)
@@ -68,7 +89,7 @@ module Redcar
68
89
  menu_header.menu = new_menu
69
90
  menu_header.add_arm_listener do
70
91
  new_menu.get_items.each {|i| i.dispose }
71
- add_entries_to_menu(new_menu, entry)
92
+ add_entries_to_menu(new_menu, nil, entry)
72
93
  end
73
94
  elsif entry.is_a?(Redcar::Menu)
74
95
  menu_header = Swt::Widgets::MenuItem.new(menu, Swt::SWT::CASCADE)
@@ -76,7 +97,9 @@ module Redcar
76
97
  new_menu = Swt::Widgets::Menu.new(menu)
77
98
  menu_header.menu = new_menu
78
99
  menu_header.enabled = (entry.length > 0)
79
- add_entries_to_menu(new_menu, entry)
100
+ new_menu_listener = MenuListener.new
101
+ add_entries_to_menu(new_menu, new_menu_listener, entry)
102
+ new_menu.add_menu_listener(new_menu_listener)
80
103
  menu_header.add_arm_listener do
81
104
  entry.entries.zip(new_menu.get_items) do |sub_entry, swt_item|
82
105
  if sub_entry.lazy_text?
@@ -88,12 +111,15 @@ module Redcar
88
111
  item = Swt::Widgets::MenuItem.new(menu, Swt::SWT::SEPARATOR)
89
112
  elsif entry.is_a?(Redcar::Menu::Item)
90
113
  item = Swt::Widgets::MenuItem.new(menu, Menu.types[entry.type] || Swt::SWT::PUSH)
91
- item.setSelection(entry.active)
92
114
  if entry.command.is_a?(Proc)
93
115
  connect_proc_to_item(item, entry)
94
116
  else
95
117
  connect_command_to_item(item, entry)
96
118
  end
119
+ if [:check, :radio].include? entry.type
120
+ menu_listener.items << [item, entry] if menu_listener
121
+ item.setSelection(entry.checked?)
122
+ end
97
123
  else
98
124
  raise "unknown object of type #{entry.class} in menu"
99
125
  end