redcar-dev 0.12.10dev-java → 0.12.11dev-java
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.
- data/lib/redcar.rb +1 -1
- data/plugins/application/lib/application.rb +1 -6
- data/plugins/application/lib/application/speedbar.rb +3 -3
- data/plugins/application_swt/lib/application_swt.rb +3 -3
- data/plugins/application_swt/lib/application_swt/speedbar/combo_item.rb +22 -5
- data/plugins/application_swt/lib/application_swt/toolbar.rb +31 -61
- data/plugins/application_swt/lib/application_swt/window.rb +1 -1
- data/plugins/redcar/redcar.rb +13 -13
- metadata +1 -1
data/lib/redcar.rb
CHANGED
@@ -185,12 +185,7 @@ module Redcar
|
|
185
185
|
@storage ||= begin
|
186
186
|
storage = Plugin::Storage.new('application_plugin')
|
187
187
|
storage.set_default('stay_resident_after_last_window_closed', false)
|
188
|
-
|
189
|
-
if Redcar.platform == :osx
|
190
|
-
storage.set_default('show_toolbar', false)
|
191
|
-
else
|
192
|
-
storage.set_default('show_toolbar', true)
|
193
|
-
end
|
188
|
+
storage.set_default('show_toolbar', true)
|
194
189
|
storage
|
195
190
|
end
|
196
191
|
end
|
@@ -7,7 +7,7 @@ module Redcar
|
|
7
7
|
ToggleItem = ObservableStruct.new(:name, :text, :key, :listener, :value)
|
8
8
|
TextBoxItem = ObservableStruct.new(:name, :listener, :value, :edit_view)
|
9
9
|
ButtonItem = ObservableStruct.new(:name, :text, :key, :listener)
|
10
|
-
ComboItem = ObservableStruct.new(:name, :items, :value, :listener)
|
10
|
+
ComboItem = ObservableStruct.new(:name, :items, :value, :editable, :listener)
|
11
11
|
SliderItem = ObservableStruct.new(:name, :value, :minimum, :maximum, :increment, :enabled, :listener)
|
12
12
|
KeyItem = ObservableStruct.new(:key, :listener)
|
13
13
|
|
@@ -79,8 +79,8 @@ module Redcar
|
|
79
79
|
define_item_finder(name)
|
80
80
|
end
|
81
81
|
|
82
|
-
def self.combo(name, items=[], value=nil,
|
83
|
-
append_item ComboItem.new(name, items, value, block)
|
82
|
+
def self.combo(name, items=[], value=nil, editable=false,&block)
|
83
|
+
append_item ComboItem.new(name, items, value, editable, block)
|
84
84
|
define_item_finder(name)
|
85
85
|
end
|
86
86
|
|
@@ -154,9 +154,9 @@ module Redcar
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def refresh_toolbar
|
157
|
-
if Redcar.platform == :osx and @fake_shell
|
158
|
-
|
159
|
-
end
|
157
|
+
# if Redcar.platform == :osx and @fake_shell
|
158
|
+
# fake_toolbar_controller = ApplicationSWT::ToolBar.new(FakeWindow.new(@fake_shell), Redcar.app.main_toolbar, Swt::SWT::FLAT)
|
159
|
+
# end
|
160
160
|
end
|
161
161
|
|
162
162
|
def add_listeners
|
@@ -3,10 +3,23 @@ module Redcar
|
|
3
3
|
class Speedbar
|
4
4
|
class ComboItem
|
5
5
|
def initialize(speedbar, composite, item)
|
6
|
-
|
6
|
+
if @editable = item.editable
|
7
|
+
type = Swt::SWT::DROP_DOWN
|
8
|
+
else
|
9
|
+
type = Swt::SWT::READ_ONLY
|
10
|
+
end
|
11
|
+
combo = Swt::Widgets::Combo.new(composite, type)
|
7
12
|
combo.items = item.items.to_java(:string)
|
8
|
-
if
|
9
|
-
combo.
|
13
|
+
if @editable
|
14
|
+
combo.set_text(item.value || "")
|
15
|
+
combo.add_modify_listener do
|
16
|
+
speedbar.ignore(item.name) do
|
17
|
+
item.value = combo.text
|
18
|
+
speedbar.execute_listener_in_model(item, item.value)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
else
|
22
|
+
combo.select(item.items.index(item.value)) if item.value
|
10
23
|
end
|
11
24
|
combo.add_selection_listener do
|
12
25
|
speedbar.ignore(item.name) do
|
@@ -18,14 +31,18 @@ module Redcar
|
|
18
31
|
speedbar.rescue_speedbar_errors do
|
19
32
|
speedbar.ignore(item.name) do
|
20
33
|
combo.items = item.items.to_java(:string)
|
21
|
-
item.value = nil
|
34
|
+
item.value = @editable ? "" : nil
|
22
35
|
end
|
23
36
|
end
|
24
37
|
end
|
25
38
|
item.add_listener(:changed_value) do |new_value|
|
26
39
|
speedbar.rescue_speedbar_errors do
|
27
40
|
speedbar.ignore(item.name) do
|
28
|
-
|
41
|
+
if @editable
|
42
|
+
combo.set_text(item.value)
|
43
|
+
else
|
44
|
+
combo.select(item.items.index(item.value))
|
45
|
+
end
|
29
46
|
end
|
30
47
|
end
|
31
48
|
end
|
@@ -7,15 +7,14 @@ module Redcar
|
|
7
7
|
|
8
8
|
def self.icons
|
9
9
|
@icons = {
|
10
|
-
:new
|
11
|
-
:open
|
12
|
-
:open_dir
|
13
|
-
:save
|
14
|
-
:save_as
|
15
|
-
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:search => File.join(Redcar.icons_directory, "binocular.png")
|
10
|
+
:new => File.join(Redcar.icons_directory, "document-text.png"),
|
11
|
+
:open => File.join(Redcar.icons_directory, "folder-open-document.png"),
|
12
|
+
:open_dir => File.join(Redcar.icons_directory, "blue-folder-horizontal-open.png"),
|
13
|
+
:save => File.join(Redcar.icons_directory, "disk.png"),
|
14
|
+
:save_as => File.join(Redcar.icons_directory, "disk--plus.png"),
|
15
|
+
:undo => File.join(Redcar.icons_directory, "arrow-circle-225-left.png"),
|
16
|
+
:redo => File.join(Redcar.icons_directory, "arrow-circle-315.png"),
|
17
|
+
:search => File.join(Redcar.icons_directory, "binocular.png")
|
19
18
|
}
|
20
19
|
end
|
21
20
|
|
@@ -30,30 +29,13 @@ module Redcar
|
|
30
29
|
attr_reader :coolbar, :toolbar, :coolitem, :toolbars, :coolitems
|
31
30
|
|
32
31
|
def initialize(window, toolbar_model, options={})
|
33
|
-
# @toolbars = {}
|
34
|
-
# @coolitems = {}
|
35
|
-
@entries = Hash.new {|h,k| h[k] = [] }
|
36
|
-
@toolbar = window.shell.getToolBar
|
37
|
-
p @toolbar
|
38
|
-
# @coolbar = Swt::Widgets::CoolBar.new(window.shell, Swt::SWT::FLAT | Swt::SWT::HORIZONTAL)
|
39
32
|
return unless toolbar_model
|
33
|
+
|
34
|
+
@entries = Hash.new {|h,k| h[k] = [] }
|
35
|
+
@toolbar = main_toolbar(window)
|
40
36
|
toolbar_model.each do |entry|
|
41
37
|
name = entry.barname || :new
|
42
38
|
@entries[name] << entry
|
43
|
-
# name = entry.barname || :new
|
44
|
-
# if not @toolbars[name]
|
45
|
-
# if name == :core
|
46
|
-
# coolitem = Swt::Widgets::CoolItem.new(@coolbar, Swt::SWT::FLAT, 0)
|
47
|
-
# else
|
48
|
-
# coolitem = Swt::Widgets::CoolItem.new(@coolbar, Swt::SWT::FLAT)
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# @toolbars[name] = create_toolbar(@coolbar)
|
52
|
-
# @coolitems[name] = coolitem
|
53
|
-
# else
|
54
|
-
# @toolbar = @toolbars[name]
|
55
|
-
# coolitem = @coolitems[name]
|
56
|
-
# end
|
57
39
|
end
|
58
40
|
add_entries_to_toolbar(@toolbar, @entries[:core])
|
59
41
|
@entries.each do |name, es|
|
@@ -61,34 +43,27 @@ module Redcar
|
|
61
43
|
add_entries_to_toolbar(@toolbar, es)
|
62
44
|
sep = Swt::Widgets::ToolItem.new(@toolbar, Swt::SWT::DEFAULT)
|
63
45
|
end
|
64
|
-
|
65
|
-
# coolitem = @coolitems[name]
|
66
|
-
# toolbar_data = @entries[name]
|
67
|
-
# coolitem.setControl(toolbar)
|
68
|
-
#
|
69
|
-
# p = toolbar.computeSize(Swt::SWT::DEFAULT, Swt::SWT::DEFAULT)
|
70
|
-
# point = coolitem.computeSize(p.x, p.y)
|
71
|
-
# coolitem.setSize(point.x, point.y)
|
72
|
-
# end
|
73
|
-
#
|
74
|
-
# @coolbar.setLocked(true)
|
75
|
-
# @coolbar.pack()
|
46
|
+
@toolbar.pack unless Redcar.platform == :osx
|
76
47
|
end
|
77
48
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
49
|
+
def main_toolbar(window)
|
50
|
+
if Redcar.platform == :osx
|
51
|
+
window.shell.getToolBar
|
52
|
+
else
|
53
|
+
Swt::Widgets::ToolBar.new(window.shell, Swt::SWT::FLAT | Swt::SWT::HORIZONTAL)
|
54
|
+
end
|
55
|
+
end
|
83
56
|
|
84
57
|
def show
|
85
|
-
# @toolbars.each_value { |toolbar| toolbar.set_visible(true) }
|
86
58
|
@toolbar.set_visible(true)
|
87
59
|
end
|
88
60
|
|
89
61
|
def hide
|
90
|
-
|
91
|
-
|
62
|
+
unless @toolbar.disposed?
|
63
|
+
@toolbar.set_visible(false)
|
64
|
+
@toolbar.getItems.each {|i| i.dispose }
|
65
|
+
# @toolbar.dispose unless Redcar.platform == :osx
|
66
|
+
end
|
92
67
|
end
|
93
68
|
|
94
69
|
def close
|
@@ -97,29 +72,24 @@ module Redcar
|
|
97
72
|
end
|
98
73
|
|
99
74
|
def height
|
100
|
-
return 0
|
101
|
-
|
102
|
-
|
103
|
-
h = ( h > i.getSize.y ) ? h : i.getSize.y
|
104
|
-
end
|
105
|
-
h
|
75
|
+
return 0 if Redcar.platform == :osx
|
76
|
+
point = @toolbar.computeSize(Swt::SWT::DEFAULT, Swt::SWT::DEFAULT, true)
|
77
|
+
return point.y
|
106
78
|
end
|
107
79
|
|
108
80
|
private
|
109
81
|
|
110
82
|
def add_entries_to_toolbar(toolbar, toolbar_model)
|
111
|
-
|
112
83
|
toolbar_model.each do |entry|
|
113
84
|
if entry.is_a?(Redcar::ToolBar::LazyToolBar)
|
114
85
|
toolbar_header = Swt::Widgets::ToolItem.new(toolbar, Swt::SWT::CASCADE)
|
115
86
|
toolbar_header.text = entry.text
|
116
|
-
#new_toolbar = Swt::Widgets::ToolBar.new(@window.shell, Swt::SWT::DROP_DOWN)
|
117
87
|
new_toolbar = Swt::Widgets::ToolBar.new(toolbar)
|
118
88
|
toolbar_header.toolbar = new_toolbar
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
89
|
+
toolbar_header.add_arm_listener do
|
90
|
+
new_toolbar.get_items.each {|i| i.dispose }
|
91
|
+
add_entries_to_toolbar(new_toolbar, entry)
|
92
|
+
end
|
123
93
|
elsif entry.is_a?(Redcar::ToolBar)
|
124
94
|
new_toolbar = Swt::Widgets::ToolBar.new(toolbar)
|
125
95
|
add_entries_to_toolbar(new_toolbar, entry)
|
@@ -159,7 +159,7 @@ module Redcar
|
|
159
159
|
def refresh_toolbar
|
160
160
|
if Redcar.app.show_toolbar?
|
161
161
|
@toolbar_controller = ApplicationSWT::ToolBar.new(self, Redcar.app.main_toolbar, Swt::SWT::HORIZONTAL | Swt::SWT::BORDER)
|
162
|
-
@toolbar_controller.show
|
162
|
+
@toolbar_controller.show
|
163
163
|
@toolbar_height = @toolbar_controller.height.to_i
|
164
164
|
else
|
165
165
|
@toolbar_controller.hide() if @toolbar_controller
|
data/plugins/redcar/redcar.rb
CHANGED
@@ -76,7 +76,7 @@ module Redcar
|
|
76
76
|
window = Redcar.app.focussed_window
|
77
77
|
Redcar.app.windows.each do |win|
|
78
78
|
@builder.item(win.title, :type => :radio, :active => (win == window)) do
|
79
|
-
FocusWindowCommand.new(win).run
|
79
|
+
Application::FocusWindowCommand.new(win).run
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -245,31 +245,31 @@ Redcar.environment: #{Redcar.environment}
|
|
245
245
|
doc.ensure_visible(doc.length)
|
246
246
|
end
|
247
247
|
end
|
248
|
-
|
248
|
+
|
249
249
|
class MoveUpCommand < EditTabCommand
|
250
250
|
def execute
|
251
251
|
tab.edit_view.invoke_action(:LINE_UP)
|
252
252
|
end
|
253
253
|
end
|
254
|
-
|
254
|
+
|
255
255
|
class MoveDownCommand < EditTabCommand
|
256
256
|
def execute
|
257
257
|
tab.edit_view.invoke_action(:LINE_DOWN)
|
258
258
|
end
|
259
259
|
end
|
260
|
-
|
260
|
+
|
261
261
|
class ForwardCharCommand < DocumentCommand
|
262
262
|
def execute
|
263
263
|
doc.cursor_offset = [doc.cursor_offset + 1, doc.length].min
|
264
264
|
end
|
265
265
|
end
|
266
|
-
|
266
|
+
|
267
267
|
class BackwardCharCommand < DocumentCommand
|
268
268
|
def execute
|
269
269
|
doc.cursor_offset = [doc.cursor_offset - 1, 0].max
|
270
270
|
end
|
271
271
|
end
|
272
|
-
|
272
|
+
|
273
273
|
class OpenLineCommand < DocumentCommand
|
274
274
|
def execute
|
275
275
|
prev = doc.cursor_offset
|
@@ -485,12 +485,12 @@ Redcar.environment: #{Redcar.environment}
|
|
485
485
|
doc.scroll_to_line(last_line_ix + 1)
|
486
486
|
end
|
487
487
|
end
|
488
|
-
|
488
|
+
|
489
489
|
class TransposeCharactersCommand < Redcar::DocumentCommand
|
490
490
|
def execute
|
491
491
|
line = doc.get_line(doc.cursor_line)
|
492
492
|
line_offset = doc.cursor_line_offset
|
493
|
-
|
493
|
+
|
494
494
|
if line_offset > 0 and line.length >= 2
|
495
495
|
if line_offset < line.length - 1
|
496
496
|
first_char = line.chars[line_offset - 1].to_s
|
@@ -858,7 +858,7 @@ Redcar.environment: #{Redcar.environment}
|
|
858
858
|
item "Quit", Application::QuitCommand
|
859
859
|
end
|
860
860
|
end
|
861
|
-
|
861
|
+
|
862
862
|
sub_menu "Edit", :priority => 5 do
|
863
863
|
group(:priority => :first) do
|
864
864
|
item "Tab Info", EditView::InfoSpeedbarCommand
|
@@ -897,17 +897,17 @@ Redcar.environment: #{Redcar.environment}
|
|
897
897
|
item "Home", MoveHomeCommand
|
898
898
|
item "End", MoveEndCommand
|
899
899
|
item "Bottom", MoveBottomCommand
|
900
|
-
|
900
|
+
|
901
901
|
separator
|
902
|
-
|
902
|
+
|
903
903
|
item "Forward Character", ForwardCharCommand
|
904
904
|
item "Backward Character", BackwardCharCommand
|
905
905
|
item "Previous Line", MoveUpCommand
|
906
906
|
item "Next Line", MoveDownCommand
|
907
907
|
item "Open Line", OpenLineCommand
|
908
|
-
|
908
|
+
|
909
909
|
separator
|
910
|
-
|
910
|
+
|
911
911
|
item "Delete Character", DeleteCharCommand
|
912
912
|
item "Backspace", BackspaceCommand
|
913
913
|
item "Transpose", TransposeCharactersCommand
|