glimmer-dsl-swt 4.18.4.9 → 4.18.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +73 -0
- data/README.md +14 -5
- data/VERSION +1 -1
- data/bin/glimmer +3 -3
- data/docs/reference/GLIMMER_CONFIGURATION.md +7 -3
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +464 -149
- data/docs/reference/GLIMMER_SAMPLES.md +91 -4
- data/glimmer-dsl-swt.gemspec +24 -13
- data/lib/ext/glimmer/config.rb +3 -7
- data/lib/glimmer/data_binding/list_selection_binding.rb +13 -7
- data/lib/glimmer/data_binding/table_items_binding.rb +22 -17
- data/lib/glimmer/data_binding/tree_items_binding.rb +19 -15
- data/lib/glimmer/data_binding/widget_binding.rb +13 -15
- data/lib/glimmer/dsl/swt/{file_dialog_expression.rb → auto_exec_expression.rb} +6 -18
- data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +9 -6
- data/lib/glimmer/dsl/swt/color_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +16 -14
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +4 -1
- data/lib/glimmer/dsl/swt/data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/swt/dialog_expression.rb +18 -9
- data/lib/glimmer/dsl/swt/dsl.rb +1 -0
- data/lib/glimmer/dsl/swt/exec_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/font_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/image_expression.rb +16 -2
- data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +11 -8
- data/lib/glimmer/dsl/swt/pixel_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +8 -5
- data/lib/glimmer/dsl/swt/shape_expression.rb +2 -2
- data/lib/glimmer/dsl/swt/shell_expression.rb +5 -2
- data/lib/glimmer/dsl/swt/widget_expression.rb +8 -4
- data/lib/glimmer/launcher.rb +3 -0
- data/lib/glimmer/rake_task/scaffold.rb +3 -0
- data/lib/glimmer/swt/color_proxy.rb +1 -1
- data/lib/glimmer/swt/custom/code_text.rb +33 -11
- data/lib/glimmer/swt/custom/drawable.rb +55 -0
- data/lib/glimmer/swt/custom/shape.rb +187 -43
- data/lib/glimmer/swt/custom/shape/arc.rb +60 -0
- data/lib/glimmer/{dsl/swt/directory_dialog_expression.rb → swt/custom/shape/focus.rb} +15 -20
- data/lib/glimmer/swt/custom/shape/image.rb +99 -0
- data/lib/glimmer/swt/custom/shape/line.rb +65 -0
- data/lib/glimmer/swt/custom/shape/oval.rb +61 -0
- data/lib/glimmer/swt/custom/shape/point.rb +54 -0
- data/lib/glimmer/swt/custom/shape/polygon.rb +73 -0
- data/lib/glimmer/swt/custom/shape/polyline.rb +74 -0
- data/lib/glimmer/swt/custom/shape/rectangle.rb +101 -0
- data/lib/glimmer/swt/custom/shape/text.rb +85 -0
- data/lib/glimmer/swt/date_time_proxy.rb +9 -3
- data/lib/glimmer/swt/dialog_proxy.rb +92 -0
- data/lib/glimmer/swt/display_proxy.rb +62 -2
- data/lib/glimmer/swt/expand_item_proxy.rb +18 -12
- data/lib/glimmer/swt/font_proxy.rb +13 -7
- data/lib/glimmer/swt/image_proxy.rb +15 -4
- data/lib/glimmer/swt/layout_data_proxy.rb +21 -15
- data/lib/glimmer/swt/layout_proxy.rb +19 -15
- data/lib/glimmer/swt/menu_proxy.rb +2 -2
- data/lib/glimmer/swt/message_box_proxy.rb +21 -7
- data/lib/glimmer/swt/properties.rb +3 -0
- data/lib/glimmer/swt/proxy_properties.rb +145 -0
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +6 -2
- data/lib/glimmer/swt/shell_proxy.rb +96 -80
- data/lib/glimmer/swt/swt_proxy.rb +17 -0
- data/lib/glimmer/swt/tab_item_proxy.rb +5 -3
- data/lib/glimmer/swt/table_proxy.rb +32 -11
- data/lib/glimmer/swt/transform_proxy.rb +39 -35
- data/lib/glimmer/swt/tree_proxy.rb +11 -16
- data/lib/glimmer/swt/widget_listener_proxy.rb +6 -2
- data/lib/glimmer/swt/widget_proxy.rb +192 -141
- data/lib/glimmer/ui.rb +5 -0
- data/lib/glimmer/ui/custom_shell.rb +13 -7
- data/lib/glimmer/ui/custom_widget.rb +4 -5
- data/samples/elaborate/contact_manager.rb +7 -7
- data/samples/elaborate/login.rb +25 -21
- data/samples/elaborate/mandelbrot_fractal.rb +87 -31
- data/samples/elaborate/meta_sample.rb +1 -1
- data/samples/elaborate/tetris.rb +1 -0
- data/samples/elaborate/tic_tac_toe.rb +16 -14
- data/samples/elaborate/tic_tac_toe/board.rb +5 -5
- data/samples/elaborate/tic_tac_toe/cell.rb +5 -5
- data/samples/hello/hello_button.rb +7 -7
- data/samples/hello/hello_canvas.rb +143 -41
- data/samples/hello/hello_checkbox.rb +16 -14
- data/samples/hello/hello_checkbox_group.rb +11 -9
- data/samples/hello/hello_color_dialog.rb +66 -0
- data/samples/hello/hello_combo.rb +14 -12
- data/samples/hello/hello_computed.rb +7 -7
- data/samples/hello/hello_cursor.rb +2 -1
- data/samples/hello/hello_custom_shell.rb +17 -21
- data/samples/hello/hello_custom_widget.rb +4 -6
- data/samples/hello/hello_date_time.rb +14 -12
- data/samples/hello/hello_directory_dialog.rb +7 -7
- data/samples/hello/hello_expand_bar.rb +8 -8
- data/samples/hello/hello_file_dialog.rb +7 -7
- data/samples/hello/hello_font_dialog.rb +82 -0
- data/samples/hello/hello_group.rb +18 -16
- data/samples/hello/hello_list_multi_selection.rb +13 -11
- data/samples/hello/hello_list_single_selection.rb +13 -11
- data/samples/hello/hello_progress_bar.rb +125 -0
- data/samples/hello/hello_radio.rb +18 -16
- data/samples/hello/hello_radio_group.rb +14 -12
- data/samples/hello/hello_spinner.rb +7 -7
- data/samples/hello/hello_tab.rb +5 -5
- data/samples/hello/hello_table.rb +10 -5
- data/samples/hello/hello_tree.rb +485 -0
- metadata +22 -22
- data/lib/glimmer/swt/directory_dialog_proxy.rb +0 -65
- data/lib/glimmer/swt/file_dialog_proxy.rb +0 -66
@@ -26,7 +26,9 @@ module Glimmer
|
|
26
26
|
module SWT
|
27
27
|
class ScrolledCompositeProxy < Glimmer::SWT::WidgetProxy
|
28
28
|
def post_initialize_child(child)
|
29
|
-
|
29
|
+
auto_exec do
|
30
|
+
swt_widget.content = child.swt_widget
|
31
|
+
end
|
30
32
|
# TODO consider triggering this method in the future upon resizing of content with a listener (on_control_resized)
|
31
33
|
# child.on_control_resized do
|
32
34
|
# swt_widget.set_min_size(swt_widget.computeSize(child.bounds.width, child.bounds.height))
|
@@ -38,7 +40,9 @@ module Glimmer
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def calculate_min_size
|
41
|
-
|
43
|
+
auto_exec do
|
44
|
+
swt_widget.set_min_size(swt_widget.computeSize(SWTProxy[:default], SWTProxy[:default]))
|
45
|
+
end
|
42
46
|
end
|
43
47
|
alias recalculate_min_size calculate_min_size
|
44
48
|
end
|
@@ -42,60 +42,64 @@ module Glimmer
|
|
42
42
|
# if swt_widget keyword arg was passed, then it is assumed the shell has already been instantiated
|
43
43
|
# and the proxy wraps it instead of creating a new one.
|
44
44
|
def initialize(*args, swt_widget: nil)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
45
|
+
auto_exec do
|
46
|
+
if swt_widget
|
47
|
+
@swt_widget = swt_widget
|
48
|
+
else
|
49
|
+
if args.first.respond_to?(:swt_widget) && args.first.swt_widget.is_a?(Shell)
|
50
|
+
@parent_proxy = args[0]
|
51
|
+
args[0] = args[0].swt_widget
|
52
|
+
end
|
53
|
+
style_args = args.select {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}.map(&:to_sym)
|
54
|
+
fill_screen = nil
|
55
|
+
if style_args.include?(:fill_screen)
|
56
|
+
args.delete(:fill_screen)
|
57
|
+
style_args.delete(:fill_screen)
|
58
|
+
fill_screen = true
|
59
|
+
end
|
60
|
+
if style_args.any?
|
61
|
+
style_arg_start_index = args.index(style_args.first)
|
62
|
+
style_arg_last_index = args.index(style_args.last)
|
63
|
+
args[style_arg_start_index..style_arg_last_index] = SWTProxy[style_args]
|
64
|
+
end
|
65
|
+
if args.first.nil? || (!args.first.is_a?(Display) && !args.first.is_a?(Shell))
|
66
|
+
@display = DisplayProxy.instance.swt_display
|
67
|
+
args = [@display] + args
|
68
|
+
end
|
69
|
+
args = args.compact
|
70
|
+
@swt_widget = Shell.new(*args)
|
71
|
+
@swt_widget.set_data('proxy', self)
|
72
|
+
@swt_widget.setLayout(FillLayout.new)
|
73
|
+
@swt_widget.setMinimumSize(WIDTH_MIN, HEIGHT_MIN)
|
74
|
+
# TODO make this an option not the default
|
75
|
+
shell_swt_display = Glimmer::SWT::DisplayProxy.instance.swt_display
|
76
|
+
on_swt_show do
|
77
|
+
@swt_widget.set_size(@display.bounds.width, @display.bounds.height) if fill_screen
|
78
|
+
Thread.new do
|
79
|
+
sleep(0.25)
|
80
|
+
shell_swt_display.async_exec do
|
81
|
+
@swt_widget.setActive unless @swt_widget.isDisposed
|
82
|
+
end
|
81
83
|
end
|
82
84
|
end
|
83
85
|
end
|
86
|
+
on_widget_disposed {
|
87
|
+
clear_shapes
|
88
|
+
}
|
89
|
+
@display ||= @swt_widget.getDisplay
|
84
90
|
end
|
85
|
-
on_widget_disposed {
|
86
|
-
clear_shapes
|
87
|
-
}
|
88
|
-
@display ||= @swt_widget.getDisplay
|
89
91
|
end
|
90
92
|
|
91
93
|
# Centers shell within monitor it is in
|
92
94
|
def center_within_display
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
95
|
+
auto_exec do
|
96
|
+
primary_monitor = @display.getPrimaryMonitor()
|
97
|
+
monitor_bounds = primary_monitor.getBounds()
|
98
|
+
shell_bounds = @swt_widget.getBounds()
|
99
|
+
location_x = monitor_bounds.x + (monitor_bounds.width - shell_bounds.width) / 2
|
100
|
+
location_y = monitor_bounds.y + (monitor_bounds.height - shell_bounds.height) / 2
|
101
|
+
@swt_widget.setLocation(location_x, location_y)
|
102
|
+
end
|
99
103
|
end
|
100
104
|
|
101
105
|
# Opens shell and starts SWT's UI thread event loop
|
@@ -107,18 +111,22 @@ module Glimmer
|
|
107
111
|
|
108
112
|
# Opens without starting the event loop.
|
109
113
|
def open_only
|
110
|
-
|
111
|
-
@
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
114
|
+
auto_exec do
|
115
|
+
if @opened_before
|
116
|
+
@swt_widget.setVisible(true)
|
117
|
+
else
|
118
|
+
@opened_before = true
|
119
|
+
@swt_widget.pack
|
120
|
+
center_within_display
|
121
|
+
@swt_widget.open
|
122
|
+
end
|
117
123
|
end
|
118
124
|
end
|
119
125
|
|
120
126
|
def nested?
|
121
|
-
|
127
|
+
auto_exec do
|
128
|
+
!swt_widget&.parent.nil?
|
129
|
+
end
|
122
130
|
end
|
123
131
|
alias nested nested?
|
124
132
|
|
@@ -129,16 +137,22 @@ module Glimmer
|
|
129
137
|
|
130
138
|
# Hides shell. Automatically checks if widget is disposed to avoid crashing.
|
131
139
|
def hide
|
132
|
-
|
140
|
+
auto_exec do
|
141
|
+
@swt_widget.setVisible(false) unless @swt_widget.isDisposed
|
142
|
+
end
|
133
143
|
end
|
134
144
|
|
135
145
|
# Closes shell. Automatically checks if widget is disposed to avoid crashing.
|
136
146
|
def close
|
137
|
-
|
147
|
+
auto_exec do
|
148
|
+
@swt_widget.close unless @swt_widget.isDisposed
|
149
|
+
end
|
138
150
|
end
|
139
151
|
|
140
152
|
def visible?
|
141
|
-
|
153
|
+
auto_exec do
|
154
|
+
@swt_widget.isDisposed ? false : @swt_widget.isVisible
|
155
|
+
end
|
142
156
|
end
|
143
157
|
alias visible visible?
|
144
158
|
|
@@ -151,25 +165,23 @@ module Glimmer
|
|
151
165
|
DisplayProxy.instance.focus_control&.shell == swt_widget
|
152
166
|
end
|
153
167
|
|
154
|
-
def pack
|
155
|
-
@swt_widget.pack
|
156
|
-
end
|
157
|
-
|
158
168
|
def pack_same_size
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
169
|
+
auto_exec do
|
170
|
+
bounds = @swt_widget.getBounds
|
171
|
+
if OS.mac?
|
172
|
+
@swt_widget.pack
|
173
|
+
@swt_widget.setBounds(bounds)
|
174
|
+
elsif OS.windows? || OS::Underlying.windows?
|
175
|
+
minimum_size = @swt_widget.getMinimumSize
|
176
|
+
@swt_widget.setMinimumSize(bounds.width, bounds.height)
|
177
|
+
listener = on_control_resized { @swt_widget.setBounds(bounds) }
|
178
|
+
@swt_widget.layout(true, true)
|
179
|
+
@swt_widget.removeControlListener(listener.swt_listener)
|
180
|
+
@swt_widget.setMinimumSize(minimum_size)
|
181
|
+
elsif OS.linux?
|
182
|
+
@swt_widget.layout(true, true)
|
183
|
+
@swt_widget.setBounds(bounds)
|
184
|
+
end
|
173
185
|
end
|
174
186
|
end
|
175
187
|
|
@@ -184,11 +196,13 @@ module Glimmer
|
|
184
196
|
# https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html
|
185
197
|
# This method is not needed except in rare circumstances where there is a need to start the SWT Event Loop before opening the shell.
|
186
198
|
def start_event_loop
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
199
|
+
auto_exec do
|
200
|
+
until @swt_widget.isDisposed
|
201
|
+
begin
|
202
|
+
@display.sleep unless @display.readAndDispatch
|
203
|
+
rescue => e
|
204
|
+
Glimmer::Config.logger.info {e.full_message}
|
205
|
+
end
|
192
206
|
end
|
193
207
|
end
|
194
208
|
end
|
@@ -209,6 +223,8 @@ module Glimmer
|
|
209
223
|
|
210
224
|
end
|
211
225
|
|
226
|
+
WindowProxy = ShellProxy
|
227
|
+
|
212
228
|
end
|
213
229
|
|
214
230
|
end
|
@@ -49,10 +49,27 @@ module Glimmer
|
|
49
49
|
def extra_styles
|
50
50
|
EXTRA_STYLES
|
51
51
|
end
|
52
|
+
|
53
|
+
def cursor_styles
|
54
|
+
SWT.constants.select {|c| c.to_s.start_with?('CURSOR_')}
|
55
|
+
end
|
56
|
+
|
57
|
+
def color_styles
|
58
|
+
SWT.constants.select {|c| c.to_s.start_with?('COLOR_')}
|
59
|
+
end
|
60
|
+
|
61
|
+
def cursor_options
|
62
|
+
cursor_styles.map {|c| c.to_s.sub('CURSOR_', '').downcase}.map(&:to_sym)
|
63
|
+
end
|
64
|
+
|
65
|
+
def color_options
|
66
|
+
color_styles.map {|c| c.to_s.sub('COLOR_', '').downcase}.map(&:to_sym)
|
67
|
+
end
|
52
68
|
end
|
53
69
|
|
54
70
|
EXTRA_STYLES = {
|
55
71
|
NO_RESIZE: self[:shell_trim, :resize!, :max!],
|
72
|
+
WINDOW_TRIM: self[:shell_trim],
|
56
73
|
}
|
57
74
|
end
|
58
75
|
end
|
@@ -266,15 +266,21 @@ module Glimmer
|
|
266
266
|
end
|
267
267
|
|
268
268
|
def items
|
269
|
-
|
269
|
+
auto_exec do
|
270
|
+
swt_widget.get_items
|
271
|
+
end
|
270
272
|
end
|
271
273
|
|
272
274
|
def model_binding
|
273
|
-
|
275
|
+
auto_exec do
|
276
|
+
swt_widget.data
|
277
|
+
end
|
274
278
|
end
|
275
279
|
|
276
280
|
def table_items_binding
|
277
|
-
|
281
|
+
auto_exec do
|
282
|
+
swt_widget.get_data('table_items_binding')
|
283
|
+
end
|
278
284
|
end
|
279
285
|
|
280
286
|
def sort_block=(comparator)
|
@@ -313,7 +319,10 @@ module Glimmer
|
|
313
319
|
|
314
320
|
# Sorts by specified TableColumnProxy object. If nil, it uses the table default sort instead.
|
315
321
|
def sort_by_column!(table_column_proxy=nil)
|
316
|
-
index =
|
322
|
+
index = nil
|
323
|
+
auto_exec do
|
324
|
+
index = swt_widget.columns.to_a.index(table_column_proxy.swt_widget) unless table_column_proxy.nil?
|
325
|
+
end
|
317
326
|
new_sort_property = table_column_proxy.nil? ? @sort_property : table_column_proxy.sort_property || [column_properties[index]]
|
318
327
|
return if table_column_proxy.nil? && new_sort_property.nil? && @sort_block.nil? && @sort_by_block.nil?
|
319
328
|
if new_sort_property && table_column_proxy.nil? && new_sort_property.size == 1 && (index = column_sort_properties.index(new_sort_property))
|
@@ -330,12 +339,16 @@ module Glimmer
|
|
330
339
|
end
|
331
340
|
|
332
341
|
@sort_direction = @sort_direction.nil? || @sort_property.first != new_sort_property.first || @sort_direction == :descending ? :ascending : :descending
|
333
|
-
|
342
|
+
auto_exec do
|
343
|
+
swt_widget.sort_direction = @sort_direction == :ascending ? SWTProxy[:up] : SWTProxy[:down]
|
344
|
+
end
|
334
345
|
|
335
346
|
@sort_property = [new_sort_property].flatten.compact
|
336
347
|
table_column_index = column_properties.index(new_sort_property.to_s.to_sym)
|
337
348
|
table_column_proxy ||= table_column_proxies[table_column_index] if table_column_index
|
338
|
-
|
349
|
+
auto_exec do
|
350
|
+
swt_widget.sort_column = table_column_proxy.swt_widget if table_column_proxy
|
351
|
+
end
|
339
352
|
|
340
353
|
if table_column_proxy
|
341
354
|
@sort_by_block = nil
|
@@ -405,14 +418,18 @@ module Glimmer
|
|
405
418
|
|
406
419
|
def cells
|
407
420
|
column_count = @table.column_properties.size
|
408
|
-
|
421
|
+
auto_exec do
|
422
|
+
swt_widget.items.map {|item| column_count.times.map {|i| item.get_text(i)} }
|
423
|
+
end
|
409
424
|
end
|
410
425
|
|
411
426
|
# Performs a search for table items matching block condition
|
412
427
|
# If no condition block is passed, returns all table items
|
413
428
|
# Returns a Java TableItem array to easily set as selection on org.eclipse.swt.Table if needed
|
414
429
|
def search(&condition)
|
415
|
-
|
430
|
+
auto_exec do
|
431
|
+
swt_widget.getItems.select {|item| condition.nil? || condition.call(item)}.to_java(TableItem)
|
432
|
+
end
|
416
433
|
end
|
417
434
|
|
418
435
|
# Returns all table items including descendants
|
@@ -454,7 +471,9 @@ module Glimmer
|
|
454
471
|
end
|
455
472
|
|
456
473
|
def edit_selected_table_item(column_index, before_write: nil, after_write: nil, after_cancel: nil)
|
457
|
-
|
474
|
+
auto_exec do
|
475
|
+
edit_table_item(swt_widget.getSelection.first, column_index, before_write: before_write, after_write: after_write, after_cancel: after_cancel)
|
476
|
+
end
|
458
477
|
end
|
459
478
|
|
460
479
|
def edit_table_item(table_item, column_index, before_write: nil, after_write: nil, after_cancel: nil, write_on_cancel: false)
|
@@ -512,7 +531,9 @@ module Glimmer
|
|
512
531
|
model.send("#{model_editing_property}=", new_value) # makes table update itself, so must search for selected table item again
|
513
532
|
# Table refresh happens here because of model update triggering observers, so must retrieve table item again
|
514
533
|
edited_table_item = search { |ti| ti.getData == model }.first
|
515
|
-
|
534
|
+
auto_exec do
|
535
|
+
swt_widget.showItem(edited_table_item)
|
536
|
+
end
|
516
537
|
@table_editor_widget_proxy&.swt_widget&.dispose
|
517
538
|
@table_editor_widget_proxy = nil
|
518
539
|
if after_write&.arity == 0
|
@@ -524,7 +545,7 @@ module Glimmer
|
|
524
545
|
end
|
525
546
|
end
|
526
547
|
end
|
527
|
-
|
548
|
+
|
528
549
|
content {
|
529
550
|
@table_editor_widget_proxy = TableProxy::editors.symbolize_keys[editor_widget][:editor_gui].call(editor_widget_args, model, model_editing_property, self)
|
530
551
|
}
|
@@ -20,7 +20,7 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
require 'glimmer/swt/display_proxy'
|
23
|
-
require 'glimmer/swt/
|
23
|
+
require 'glimmer/swt/proxy_properties'
|
24
24
|
require 'glimmer/swt/custom/shape'
|
25
25
|
|
26
26
|
module Glimmer
|
@@ -29,7 +29,7 @@ module Glimmer
|
|
29
29
|
#
|
30
30
|
# Follows the Proxy Design Pattern
|
31
31
|
class TransformProxy
|
32
|
-
include
|
32
|
+
include ProxyProperties
|
33
33
|
|
34
34
|
include_package 'org.eclipse.swt.graphics'
|
35
35
|
include_package 'org.eclipse.swt.widgets'
|
@@ -37,32 +37,36 @@ module Glimmer
|
|
37
37
|
attr_reader :swt_transform, :parent
|
38
38
|
|
39
39
|
def initialize(parent, *args, swt_transform: nil, multiply: false)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
if
|
44
|
-
args.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
40
|
+
Glimmer::SWT::DisplayProxy.instance.auto_exec do
|
41
|
+
@parent = parent
|
42
|
+
@multiply = multiply
|
43
|
+
if swt_transform.nil?
|
44
|
+
if !args.first.is_a?(Display) && !args.first.is_a?(DisplayProxy)
|
45
|
+
args.prepend DisplayProxy.instance.swt_display
|
46
|
+
end
|
47
|
+
if args.first.is_a?(DisplayProxy)
|
48
|
+
args[0] = args[0].swt_display
|
49
|
+
end
|
50
|
+
if args.last.is_a?(TransformProxy)
|
51
|
+
args[-1] = args[-1].swt_transform
|
52
|
+
end
|
53
|
+
if args.last.nil? || args.last.is_a?(Transform)
|
54
|
+
@swt_transform = args.last
|
55
|
+
@parent&.set_attribute('transform', self)
|
56
|
+
else
|
57
|
+
@swt_transform = Transform.new(*args)
|
58
|
+
end
|
55
59
|
else
|
56
|
-
@swt_transform =
|
60
|
+
@swt_transform = swt_transform
|
57
61
|
end
|
58
|
-
else
|
59
|
-
@swt_transform = swt_transform
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
63
65
|
def post_add_content
|
64
66
|
if @multiply
|
65
|
-
|
67
|
+
Glimmer::SWT::DisplayProxy.instance.auto_exec {
|
68
|
+
@parent.multiply(@swt_transform)
|
69
|
+
}
|
66
70
|
else
|
67
71
|
@parent&.set_attribute('transform', self)
|
68
72
|
end
|
@@ -72,32 +76,32 @@ module Glimmer
|
|
72
76
|
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::TransformExpression.new, &block)
|
73
77
|
end
|
74
78
|
|
79
|
+
def proxy_source_object
|
80
|
+
@swt_transform
|
81
|
+
end
|
82
|
+
|
75
83
|
def has_attribute?(attribute_name, *args)
|
76
|
-
@swt_transform.respond_to?(attribute_name) ||
|
84
|
+
Glimmer::SWT::DisplayProxy.instance.auto_exec { @swt_transform.respond_to?(attribute_name) } || super
|
77
85
|
end
|
78
86
|
|
79
87
|
def set_attribute(attribute_name, *args)
|
80
88
|
if @swt_transform.respond_to?(attribute_name)
|
81
|
-
@swt_transform.send(attribute_name, *args)
|
82
|
-
elsif @swt_transform.respond_to?(attribute_setter(attribute_name))
|
83
|
-
@swt_transform.send(attribute_setter(attribute_name), *args)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def get_attribute(attribute_name)
|
88
|
-
if @swt_transform.respond_to?(attribute_getter(attribute_name))
|
89
|
-
@swt_transform.send(attribute_getter(attribute_name))
|
89
|
+
Glimmer::SWT::DisplayProxy.instance.auto_exec { @swt_transform.send(attribute_name, *args) }
|
90
90
|
else
|
91
|
-
|
91
|
+
super
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
def method_missing(method_name, *args, &block)
|
96
|
-
result = @swt_transform.send(method_name, *args, &block)
|
96
|
+
result = Glimmer::SWT::DisplayProxy.instance.auto_exec { @swt_transform.send(method_name, *args, &block) }
|
97
97
|
result.nil? ? self : result
|
98
98
|
rescue => e
|
99
|
-
|
100
|
-
|
99
|
+
begin
|
100
|
+
super
|
101
|
+
rescue Exception => inner_e
|
102
|
+
Glimmer::Config.logger.error {"Neither TransformProxy nor #{@swt_transform.class.name} can handle the method ##{method}"}
|
103
|
+
Glimmer::Config.logger.error {e.full_message}
|
104
|
+
end
|
101
105
|
end
|
102
106
|
|
103
107
|
def respond_to?(method, *args, &block)
|