Class: Redcar::ApplicationSWT::Speedbar
- Inherits:
-
Object
- Object
- Redcar::ApplicationSWT::Speedbar
show all
- Includes:
- ReentryHelpers
- Defined in:
- plugins/application_swt/lib/application_swt/speedbar.rb,
plugins/application_swt/lib/application_swt/speedbar/combo_item.rb,
plugins/application_swt/lib/application_swt/speedbar/label_item.rb,
plugins/application_swt/lib/application_swt/speedbar/toggle_item.rb,
plugins/application_swt/lib/application_swt/speedbar/slider_item.rb,
plugins/application_swt/lib/application_swt/speedbar/button_item.rb,
plugins/application_swt/lib/application_swt/speedbar/text_box_item.rb
Defined Under Namespace
Classes: ButtonItem, ComboItem, KeyListener, LabelItem, MouseListener, SliderItem, TextBoxItem, ToggleItem
Instance Attribute Summary (collapse)
Instance Method Summary
(collapse)
#ignore, #ignore_changes
Constructor Details
- (Speedbar) initialize(window, parent, model)
A new instance of Speedbar
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 15
def initialize(window, parent, model)
@window_model = window
@parent = parent
@model = model
create_widgets
attach_key_listeners
if widget = focussable_widgets.first
widget.set_focus
end
@handlers = Hash.new {|h,k| h[k] = []}
@parent.layout
@model.after_draw if @model.respond_to?(:after_draw)
end
|
Instance Attribute Details
Returns the value of attribute widget
13
14
15
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 13
def widget
@widget
end
|
Instance Method Details
- (Object) attach_key_listeners
131
132
133
134
135
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 131
def attach_key_listeners
keyable_widgets.each do |widget|
widget.add_key_listener(KeyListener.new(self))
end
end
|
30
31
32
33
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 30
def close
@composite.dispose
@parent.layout
end
|
- (Object) close_pressed
137
138
139
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 137
def close_pressed
@window_model.close_speedbar
end
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 69
def create_bar_widget
@composite = Swt::Widgets::Composite.new(@parent, Swt::SWT::NONE)
grid_data = Swt::Layout::GridData.new
grid_data.grabExcessHorizontalSpace = true
grid_data.horizontalAlignment = Swt::Layout::GridData::FILL
@composite.setLayoutData(grid_data)
layout = Swt::Layout::GridLayout.new(num_columns + 1, false)
layout.verticalSpacing = 0
layout.marginHeight = 0
layout.marginTop = 5
@composite.setLayout(layout)
image = Swt::Graphics::Image.new(ApplicationSWT.display, Redcar::Speedbar.close_image_path)
label = Swt::Widgets::Label.new(@composite, 0)
label.set_image(image)
label.add_mouse_listener(MouseListener.new(self))
end
|
97
98
99
100
101
102
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 97
def create_item_widgets
@model.__items.each do |item|
swt_klass = self.class.const_get(item.class.to_s.split("::").last)
swt_klass.new(self, @composite, item)
end
end
|
64
65
66
67
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 64
def create_widgets
create_bar_widget
create_item_widgets
end
|
35
36
37
38
39
40
41
42
43
44
45
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 35
def
key_strings = []
@model.__items.each do |i|
if i.respond_to?(:key)
key_strings << i.key
end
end
key_strings.uniq.each do |key_string|
ApplicationSWT::Menu.disable_items(key_string)
end
end
|
- (Object) error_in_listener(e)
174
175
176
177
178
179
180
181
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 174
def error_in_listener(e)
if e.class.name == "TestingError"
raise e
else
puts "*** Error in speedbar listener: #{e.message}"
puts e.backtrace.map {|l| " " + l}
end
end
|
- (Object) execute_listener_in_model(item, *args)
87
88
89
90
91
92
93
94
95
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 87
def execute_listener_in_model(item, *args)
if item.listener
begin
@model.instance_exec(*args, &item.listener)
rescue => err
error_in_listener(err)
end
end
end
|
60
61
62
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 60
def focussable_widgets
@focussable_widgets ||= []
end
|
- (Object) key_items
52
53
54
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 52
def key_items
@model.__items.select {|i| i.respond_to?(:key) and i.key }
end
|
- (Object) key_press(e)
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 141
def key_press(e)
return if Application::Dialog.in_dialog?
key_string = Menu::BindingTranslator.key_string(e)
if key_string == "\e"
@window_model.close_speedbar
e.doit = false
end
key_items.each do |key_item|
if Menu::BindingTranslator.matches?(key_string, key_item.key)
e.doit = false
begin
@model.instance_exec(&key_item.listener)
rescue Object => err
error_in_listener(err)
end
end
end
end
|
56
57
58
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 56
def keyable_widgets
@keyable_widgets ||= []
end
|
- (Object) num_columns
47
48
49
50
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 47
def num_columns
return @model.num_columns if @model.respond_to?(:num_columns)
@model.__items.select {|i| !i.is_a?(Redcar::Speedbar::KeyItem) }.length
end
|
- (Object) rescue_speedbar_errors
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'plugins/application_swt/lib/application_swt/speedbar.rb', line 160
def rescue_speedbar_errors
begin
yield
rescue Object => e
if e.class.name == "TestingError"
raise e
else
puts "*** Error in speedbar"
puts e.class.to_s + ": " + e.message
puts e.backtrace
end
end
end
|