glimmer-dsl-swt 4.17.10.8 → 4.18.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -0
- data/LICENSE.txt +1 -1
- data/README.md +529 -60
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/bin/girb +1 -1
- data/bin/girb_runner.rb +1 -1
- data/bin/glimmer +1 -1
- data/glimmer-dsl-swt.gemspec +58 -30
- data/lib/ext/glimmer.rb +1 -1
- data/lib/ext/glimmer/config.rb +7 -7
- data/lib/glimmer-dsl-swt.rb +3 -1
- data/lib/glimmer/Rakefile +1 -1
- data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
- data/lib/glimmer/data_binding/observable_widget.rb +1 -1
- data/lib/glimmer/data_binding/shine.rb +1 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +1 -1
- data/lib/glimmer/data_binding/tree_items_binding.rb +1 -1
- data/lib/glimmer/data_binding/widget_binding.rb +1 -1
- data/lib/glimmer/dsl/swt/animation_expression.rb +43 -0
- data/lib/glimmer/dsl/swt/async_exec_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/bind_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/block_property_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/color_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/column_properties_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/cursor_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/dialog_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/directory_dialog_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/display_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/dnd_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/dsl.rb +5 -4
- data/lib/glimmer/dsl/swt/exec_expression.rb +5 -5
- data/lib/glimmer/dsl/swt/expand_item_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/file_dialog_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/font_expression.rb +8 -6
- data/lib/glimmer/dsl/swt/image_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/layout_data_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/layout_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/menu_bar_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/menu_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/message_box_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/observe_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/property_expression.rb +4 -4
- data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/rgb_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/rgba_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/shape_expression.rb +56 -0
- data/lib/glimmer/dsl/swt/shell_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/swt_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/sync_exec_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/tab_item_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/tree_properties_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/widget_expression.rb +7 -3
- data/lib/glimmer/dsl/swt/widget_listener_expression.rb +1 -1
- data/lib/glimmer/launcher.rb +1 -1
- data/lib/glimmer/rake_task.rb +1 -1
- data/lib/glimmer/rake_task/list.rb +6 -6
- data/lib/glimmer/rake_task/package.rb +1 -1
- data/lib/glimmer/rake_task/scaffold.rb +33 -34
- data/lib/glimmer/swt/color_proxy.rb +1 -1
- data/lib/glimmer/swt/cursor_proxy.rb +1 -1
- data/lib/glimmer/swt/custom/animation.rb +120 -0
- data/lib/glimmer/swt/custom/checkbox_group.rb +1 -1
- data/lib/glimmer/swt/custom/drawable.rb +43 -0
- data/lib/glimmer/swt/custom/radio_group.rb +1 -1
- data/lib/glimmer/swt/custom/shape.rb +154 -0
- data/lib/glimmer/swt/date_time_proxy.rb +1 -1
- data/lib/glimmer/swt/directory_dialog_proxy.rb +1 -1
- data/lib/glimmer/swt/display_proxy.rb +17 -1
- data/lib/glimmer/swt/dnd_proxy.rb +1 -1
- data/lib/glimmer/swt/expand_item_proxy.rb +1 -1
- data/lib/glimmer/swt/file_dialog_proxy.rb +1 -1
- data/lib/glimmer/swt/font_proxy.rb +4 -4
- data/lib/glimmer/swt/image_proxy.rb +12 -11
- data/lib/glimmer/swt/layout_data_proxy.rb +1 -1
- data/lib/glimmer/swt/layout_proxy.rb +8 -4
- data/lib/glimmer/swt/menu_proxy.rb +10 -5
- data/lib/glimmer/swt/message_box_proxy.rb +1 -1
- data/lib/glimmer/swt/packages.rb +1 -1
- data/lib/glimmer/swt/properties.rb +49 -0
- data/lib/glimmer/swt/sash_form_proxy.rb +2 -2
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +1 -1
- data/lib/glimmer/swt/shell_proxy.rb +3 -2
- data/lib/glimmer/swt/style_constantizable.rb +9 -5
- data/lib/glimmer/swt/styled_text_proxy.rb +1 -1
- data/lib/glimmer/swt/swt_proxy.rb +1 -1
- data/lib/glimmer/swt/tab_item_proxy.rb +1 -1
- data/lib/glimmer/swt/table_column_proxy.rb +1 -1
- data/lib/glimmer/swt/table_proxy.rb +1 -1
- data/lib/glimmer/swt/tree_proxy.rb +26 -22
- data/lib/glimmer/swt/widget_listener_proxy.rb +1 -1
- data/lib/glimmer/swt/widget_proxy.rb +54 -28
- data/lib/glimmer/ui/custom_shell.rb +1 -1
- data/lib/glimmer/ui/custom_widget.rb +1 -1
- data/lib/glimmer/util/proc_tracker.rb +1 -1
- data/samples/elaborate/contact_manager.rb +1 -1
- data/samples/elaborate/contact_manager/contact.rb +1 -1
- data/samples/elaborate/contact_manager/contact_manager_presenter.rb +1 -1
- data/samples/elaborate/contact_manager/contact_repository.rb +1 -1
- data/samples/elaborate/login.rb +1 -1
- data/samples/elaborate/meta_sample.rb +40 -16
- data/samples/elaborate/tic_tac_toe.rb +2 -2
- data/samples/elaborate/tic_tac_toe/board.rb +1 -1
- data/samples/elaborate/tic_tac_toe/cell.rb +1 -1
- data/samples/elaborate/user_profile.rb +1 -1
- data/samples/hello/hello_browser.rb +1 -1
- data/samples/hello/hello_button.rb +1 -1
- data/samples/hello/hello_canvas.rb +43 -0
- data/samples/hello/hello_canvas_animation.rb +66 -0
- data/samples/hello/hello_checkbox.rb +1 -1
- data/samples/hello/hello_checkbox_group.rb +1 -1
- data/samples/hello/hello_combo.rb +1 -1
- data/samples/hello/hello_computed.rb +1 -1
- data/samples/hello/hello_computed/contact.rb +1 -1
- data/samples/hello/hello_custom_shell.rb +1 -1
- data/samples/hello/hello_custom_widget.rb +1 -1
- data/samples/hello/hello_date_time.rb +1 -1
- data/samples/hello/hello_dialog.rb +78 -0
- data/samples/hello/hello_directory_dialog.rb +1 -1
- data/samples/hello/hello_drag_and_drop.rb +1 -1
- data/samples/hello/hello_expand_bar.rb +1 -1
- data/samples/hello/hello_file_dialog.rb +1 -1
- data/samples/hello/hello_group.rb +1 -1
- data/samples/hello/hello_link.rb +1 -1
- data/samples/hello/hello_list_multi_selection.rb +1 -1
- data/samples/hello/hello_list_single_selection.rb +1 -1
- data/samples/hello/hello_menu_bar.rb +185 -29
- data/samples/hello/hello_message_box.rb +1 -1
- data/samples/hello/hello_pop_up_context_menu.rb +1 -1
- data/samples/hello/hello_radio.rb +1 -1
- data/samples/hello/hello_radio_group.rb +1 -1
- data/samples/hello/hello_sash_form.rb +1 -1
- data/samples/hello/hello_spinner.rb +1 -1
- data/samples/hello/hello_styled_text.rb +1 -1
- data/samples/hello/hello_tab.rb +1 -1
- data/samples/hello/hello_table.rb +1 -1
- data/samples/hello/hello_world.rb +1 -1
- data/vendor/swt/linux/swt.jar +0 -0
- data/vendor/swt/mac/swt.jar +0 -0
- data/vendor/swt/windows/swt.jar +0 -0
- metadata +54 -32
@@ -1,5 +1,5 @@
|
|
1
|
-
# Copyright (c) 2007-
|
2
|
-
#
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -54,9 +54,9 @@ module Glimmer
|
|
54
54
|
@args = @args.first if @args.size == 1 && @args.first.is_a?(Array)
|
55
55
|
if options&.keys&.include?(:swt_image)
|
56
56
|
@swt_image = options[:swt_image]
|
57
|
-
@image_data = @swt_image.image_data
|
57
|
+
@original_image_data = @image_data = @swt_image.image_data
|
58
58
|
elsif @file_path
|
59
|
-
@image_data = ImageData.new(input_stream || @file_path)
|
59
|
+
@original_image_data = @image_data = ImageData.new(input_stream || @file_path)
|
60
60
|
@swt_image = Image.new(DisplayProxy.instance.swt_display, @image_data)
|
61
61
|
width = options[:width]
|
62
62
|
height = options[:height]
|
@@ -65,8 +65,8 @@ module Glimmer
|
|
65
65
|
scale_to(width, height) unless width.nil? || height.nil?
|
66
66
|
else
|
67
67
|
@swt_image = Image.new(*@args)
|
68
|
-
@image_data = @swt_image.image_data
|
69
|
-
end
|
68
|
+
@original_image_data = @image_data = @swt_image.image_data
|
69
|
+
end
|
70
70
|
end
|
71
71
|
|
72
72
|
def input_stream
|
@@ -77,12 +77,13 @@ module Glimmer
|
|
77
77
|
file_input_stream = object.java_class.resource_as_stream(file_path)
|
78
78
|
else
|
79
79
|
file_input_stream = java.io.FileInputStream.new(@file_path)
|
80
|
-
end
|
80
|
+
end
|
81
81
|
java.io.BufferedInputStream.new(file_input_stream) if file_input_stream
|
82
82
|
end
|
83
83
|
|
84
84
|
def scale_to(width, height)
|
85
|
-
|
85
|
+
return if @image_data.width == width && @image_data.height == height
|
86
|
+
scaled_image_data = @original_image_data.scaledTo(width, height)
|
86
87
|
device = swt_image.device
|
87
88
|
swt_image.dispose
|
88
89
|
@swt_image = Image.new(device, scaled_image_data)
|
@@ -99,7 +100,7 @@ module Glimmer
|
|
99
100
|
|
100
101
|
def respond_to?(method, *args, &block)
|
101
102
|
super || swt_image.respond_to?(method, *args, &block)
|
102
|
-
end
|
103
|
+
end
|
103
104
|
end
|
104
105
|
end
|
105
106
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# Copyright (c) 2007-
|
2
|
-
#
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -68,6 +68,10 @@ module Glimmer
|
|
68
68
|
@swt_layout = self.class.swt_layout_class_for(underscored_layout_name).new(*args)
|
69
69
|
@swt_layout.marginWidth = 15 if @swt_layout.respond_to?(:marginWidth)
|
70
70
|
@swt_layout.marginHeight = 15 if @swt_layout.respond_to?(:marginHeight)
|
71
|
+
@swt_layout.marginTop = 0 if @swt_layout.respond_to?(:marginTop)
|
72
|
+
@swt_layout.marginRight = 0 if @swt_layout.respond_to?(:marginRight)
|
73
|
+
@swt_layout.marginBottom = 0 if @swt_layout.respond_to?(:marginBottom)
|
74
|
+
@swt_layout.marginLeft = 0 if @swt_layout.respond_to?(:marginLeft)
|
71
75
|
@widget_proxy.swt_widget.setLayout(@swt_layout)
|
72
76
|
end
|
73
77
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2007-
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -75,7 +75,7 @@ module Glimmer
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def has_attribute?(attribute_name, *args)
|
78
|
-
if attribute_name.to_s
|
78
|
+
if ['text', 'enabled'].include?(attribute_name.to_s)
|
79
79
|
true
|
80
80
|
else
|
81
81
|
super(attribute_name, *args)
|
@@ -83,24 +83,29 @@ module Glimmer
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def set_attribute(attribute_name, *args)
|
86
|
-
attribute_name
|
87
|
-
if attribute_name.to_s == "text"
|
86
|
+
if normalized_attribute(attribute_name) == 'text'
|
88
87
|
text_value = args[0]
|
89
88
|
@swt_menu_item.setText text_value
|
89
|
+
elsif normalized_attribute(attribute_name) == 'enabled'
|
90
|
+
value = args[0]
|
91
|
+
@swt_menu_item.setEnabled value
|
90
92
|
else
|
91
93
|
super(attribute_name, *args)
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
95
97
|
def get_attribute(attribute_name)
|
96
|
-
if attribute_name
|
98
|
+
if normalized_attribute(attribute_name) == 'text'
|
97
99
|
@swt_menu_item.getText
|
100
|
+
elsif normalized_attribute(attribute_name) == 'enabled'
|
101
|
+
@swt_menu_item.getEnabled
|
98
102
|
else
|
99
103
|
super(attribute_name)
|
100
104
|
end
|
101
105
|
end
|
102
106
|
|
103
107
|
def can_handle_observation_request?(observation_request, super_only: false)
|
108
|
+
observation_request = observation_request.to_s
|
104
109
|
super_result = super(observation_request)
|
105
110
|
if observation_request.start_with?('on_') && !super_result && !super_only
|
106
111
|
return menu_item_proxy.can_handle_observation_request?(observation_request)
|
data/lib/glimmer/swt/packages.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
module Glimmer
|
23
|
+
module SWT
|
24
|
+
module Properties
|
25
|
+
def ruby_attribute_setter(attribute_name)
|
26
|
+
"#{normalized_attribute(attribute_name)}="
|
27
|
+
end
|
28
|
+
|
29
|
+
def attribute_setter(attribute_name)
|
30
|
+
"set#{normalized_attribute(attribute_name).camelcase(:upper)}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def attribute_getter(attribute_name)
|
34
|
+
"get#{normalized_attribute(attribute_name).camelcase(:upper)}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def normalized_attribute(attribute_name)
|
38
|
+
attribute_name = attribute_name.to_s if attribute_name.is_a?(Symbol)
|
39
|
+
attribute_name = attribute_name.underscore unless attribute_name.downcase?
|
40
|
+
attribute_name = attribute_name.sub(/^get_/, '') if attribute_name.start_with?('get_')
|
41
|
+
attribute_name = attribute_name.sub(/^set_/, '') if attribute_name.start_with?('set_')
|
42
|
+
attribute_name = attribute_name.sub(/=$/, '') if attribute_name.end_with?('=')
|
43
|
+
attribute_name
|
44
|
+
end
|
45
|
+
alias ruby_attribute_getter normalized_attribute
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2007-
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -28,7 +28,7 @@ module Glimmer
|
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class SashFormProxy < WidgetProxy
|
30
30
|
def post_add_content
|
31
|
-
|
31
|
+
self.weights = @weights unless @weights.nil?
|
32
32
|
end
|
33
33
|
|
34
34
|
def set_attribute(attribute_name, *args)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2007-
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -64,10 +64,11 @@ module Glimmer
|
|
64
64
|
@swt_widget.setLayout(FillLayout.new)
|
65
65
|
@swt_widget.setMinimumSize(WIDTH_MIN, HEIGHT_MIN)
|
66
66
|
# TODO make this an option not the default
|
67
|
+
shell_swt_display = Glimmer::SWT::DisplayProxy.instance.swt_display
|
67
68
|
on_swt_show do
|
68
69
|
Thread.new do
|
69
70
|
sleep(0.25)
|
70
|
-
async_exec do
|
71
|
+
shell_swt_display.async_exec do
|
71
72
|
@swt_widget.setActive unless @swt_widget.isDisposed
|
72
73
|
end
|
73
74
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2007-
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -89,11 +89,15 @@ module Glimmer
|
|
89
89
|
negative ? ~bit_value : bit_value
|
90
90
|
rescue => e
|
91
91
|
# Glimmer::Config.logger.debug {e.full_message}
|
92
|
-
|
93
|
-
|
94
|
-
negative ? ~bit_value : bit_value
|
92
|
+
if symbol.to_s.size == 1 # accelerator key
|
93
|
+
symbol.to_s.bytes.first
|
95
94
|
else
|
96
|
-
|
95
|
+
bit_value = extra_styles[swt_constant_symbol]
|
96
|
+
if bit_value
|
97
|
+
negative ? ~bit_value : bit_value
|
98
|
+
else
|
99
|
+
symbol
|
100
|
+
end
|
97
101
|
end
|
98
102
|
end
|
99
103
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# Copyright (c) 2007-
|
2
|
-
#
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -59,7 +59,7 @@ module Glimmer
|
|
59
59
|
observer.call(@swt_widget.getSelection)
|
60
60
|
}
|
61
61
|
end
|
62
|
-
},
|
62
|
+
},
|
63
63
|
})
|
64
64
|
end
|
65
65
|
|
@@ -85,24 +85,28 @@ module Glimmer
|
|
85
85
|
@edit_in_progress = false
|
86
86
|
}
|
87
87
|
action = lambda { |event|
|
88
|
-
|
89
|
-
action_taken
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
88
|
+
begin
|
89
|
+
if !action_taken && !@edit_in_progress
|
90
|
+
action_taken = true
|
91
|
+
@edit_in_progress = true
|
92
|
+
new_text = @tree_editor_text_proxy.swt_widget.getText
|
93
|
+
if new_text == tree_item.getText
|
94
|
+
cancel.call
|
95
|
+
else
|
96
|
+
before_write&.call
|
97
|
+
tree_item.setText(new_text)
|
98
|
+
model = tree_item.getData
|
99
|
+
model.send("#{tree_properties[:text]}=", new_text) # makes tree update itself, so must search for selected tree item again
|
100
|
+
edited_tree_item = depth_first_search { |ti| ti.getData == model }.first
|
101
|
+
swt_widget.showItem(edited_tree_item)
|
102
|
+
@tree_editor_text_proxy.swt_widget.dispose
|
103
|
+
@tree_editor_text_proxy = nil
|
104
|
+
after_write&.call(edited_tree_item)
|
105
|
+
@edit_in_progress = false
|
106
|
+
end
|
105
107
|
end
|
108
|
+
rescue => e
|
109
|
+
Glimmer::Config.logger.error {"Error encountered while editing tree item!\n#{e.full_message}"}
|
106
110
|
end
|
107
111
|
}
|
108
112
|
on_focus_lost(&action)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2007-
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -26,6 +26,8 @@ require 'glimmer/swt/swt_proxy'
|
|
26
26
|
require 'glimmer/swt/display_proxy'
|
27
27
|
require 'glimmer/swt/dnd_proxy'
|
28
28
|
require 'glimmer/swt/image_proxy'
|
29
|
+
require 'glimmer/swt/properties'
|
30
|
+
require 'glimmer/swt/custom/drawable'
|
29
31
|
|
30
32
|
# TODO refactor to make file smaller and extract sub-widget-proxies out of this
|
31
33
|
|
@@ -42,6 +44,8 @@ module Glimmer
|
|
42
44
|
# Follows the Proxy Design Pattern
|
43
45
|
class WidgetProxy
|
44
46
|
include Packages
|
47
|
+
include Properties
|
48
|
+
include Custom::Drawable
|
45
49
|
|
46
50
|
DEFAULT_STYLES = {
|
47
51
|
'arrow' => [:arrow],
|
@@ -202,7 +206,22 @@ module Glimmer
|
|
202
206
|
end
|
203
207
|
end
|
204
208
|
|
209
|
+
def has_attribute_getter?(attribute_getter_name, *args)
|
210
|
+
attribute_getter_name = attribute_getter_name.to_s.underscore
|
211
|
+
return false unless !attribute_getter_name.end_with?('=') && !attribute_getter_name.start_with?('set_')
|
212
|
+
args.empty? && swt_widget.respond_to?(attribute_getter_name)
|
213
|
+
end
|
214
|
+
|
215
|
+
def has_attribute_setter?(attribute_setter_name, *args)
|
216
|
+
attribute_setter_name = attribute_setter_name.to_s
|
217
|
+
underscored_attribute_setter_name = attribute_setter_name.underscore
|
218
|
+
return false unless attribute_setter_name.end_with?('=') || (attribute_setter_name.start_with?('set_') && !args.empty?)
|
219
|
+
attribute_name = underscored_attribute_setter_name.sub(/^set_/, '').sub(/=$/, '')
|
220
|
+
has_attribute?(attribute_name, *args)
|
221
|
+
end
|
222
|
+
|
205
223
|
def has_attribute?(attribute_name, *args)
|
224
|
+
# TODO test that attribute getter responds too
|
206
225
|
widget_custom_attribute = widget_custom_attribute_mapping[attribute_name.to_s]
|
207
226
|
if widget_custom_attribute
|
208
227
|
@swt_widget.respond_to?(widget_custom_attribute[:setter][:name])
|
@@ -214,11 +233,13 @@ module Glimmer
|
|
214
233
|
def set_attribute(attribute_name, *args)
|
215
234
|
# TODO Think about widget subclasses overriding set_attribute to add more attributes vs adding as Ruby attributes directly
|
216
235
|
widget_custom_attribute = widget_custom_attribute_mapping[attribute_name.to_s]
|
236
|
+
apply_property_type_converters(normalized_attribute(attribute_name), args)
|
217
237
|
if widget_custom_attribute
|
218
238
|
widget_custom_attribute[:setter][:invoker].call(@swt_widget, args)
|
219
239
|
elsif @swt_widget.respond_to?(attribute_setter(attribute_name))
|
220
|
-
apply_property_type_converters(attribute_name, args)
|
221
240
|
@swt_widget.send(attribute_setter(attribute_name), *args) unless @swt_widget.send(attribute_getter(attribute_name)) == args.first
|
241
|
+
elsif @swt_widget.respond_to?(ruby_attribute_setter(attribute_name))
|
242
|
+
@swt_widget.send(ruby_attribute_setter(attribute_name), args)
|
222
243
|
else
|
223
244
|
send(ruby_attribute_setter(attribute_name), args)
|
224
245
|
end
|
@@ -234,6 +255,12 @@ module Glimmer
|
|
234
255
|
end
|
235
256
|
elsif @swt_widget.respond_to?(attribute_getter(attribute_name))
|
236
257
|
@swt_widget.send(attribute_getter(attribute_name))
|
258
|
+
elsif @swt_widget.respond_to?(ruby_attribute_getter(attribute_name))
|
259
|
+
@swt_widget.send(ruby_attribute_getter(attribute_name))
|
260
|
+
elsif @swt_widget.respond_to?(attribute_name)
|
261
|
+
@swt_widget.send(attribute_name)
|
262
|
+
elsif respond_to?(ruby_attribute_getter(attribute_name))
|
263
|
+
send(ruby_attribute_getter(attribute_name))
|
237
264
|
else
|
238
265
|
send(attribute_name)
|
239
266
|
end
|
@@ -608,11 +635,16 @@ module Glimmer
|
|
608
635
|
def method_missing(method, *args, &block)
|
609
636
|
if can_handle_observation_request?(method)
|
610
637
|
handle_observation_request(method, &block)
|
638
|
+
elsif has_attribute_setter?(method, *args)
|
639
|
+
set_attribute(method, *args)
|
640
|
+
elsif has_attribute_getter?(method, *args)
|
641
|
+
get_attribute(method, *args)
|
611
642
|
else
|
612
643
|
swt_widget.send(method, *args, &block)
|
613
644
|
end
|
614
645
|
rescue => e
|
615
|
-
Glimmer::Config.logger.debug {"Neither WidgetProxy nor #{swt_widget.class.name} can handle the method ##{method}"}
|
646
|
+
Glimmer::Config.logger.debug { "Neither WidgetProxy nor #{swt_widget.class.name} can handle the method ##{method}" }
|
647
|
+
Glimmer::Config.logger.debug { e.full_message }
|
616
648
|
super
|
617
649
|
# TODO consider get_attribute too
|
618
650
|
end
|
@@ -639,18 +671,6 @@ module Glimmer
|
|
639
671
|
DEFAULT_STYLES[underscored_widget_name] || [:none]
|
640
672
|
end
|
641
673
|
|
642
|
-
def ruby_attribute_setter(attribute_name)
|
643
|
-
"#{attribute_name}="
|
644
|
-
end
|
645
|
-
|
646
|
-
def attribute_setter(attribute_name)
|
647
|
-
"set#{attribute_name.to_s.camelcase(:upper)}"
|
648
|
-
end
|
649
|
-
|
650
|
-
def attribute_getter(attribute_name)
|
651
|
-
"get#{attribute_name.to_s.camelcase(:upper)}"
|
652
|
-
end
|
653
|
-
|
654
674
|
# TODO refactor following methods to eliminate duplication
|
655
675
|
# perhaps consider relying on raising an exception to avoid checking first
|
656
676
|
# unless that gives obscure SWT errors
|
@@ -800,11 +820,14 @@ module Glimmer
|
|
800
820
|
end
|
801
821
|
# TODO consider detecting type on widget method and automatically invoking right converter (e.g. :to_s for String, :to_i for Integer)
|
802
822
|
@property_type_converters ||= {
|
803
|
-
|
823
|
+
accelerator: lambda { |*value|
|
804
824
|
SWTProxy[*value]
|
805
825
|
},
|
806
|
-
:
|
807
|
-
|
826
|
+
alignment: lambda { |*value|
|
827
|
+
SWTProxy[*value]
|
828
|
+
},
|
829
|
+
background: color_converter,
|
830
|
+
background_image: lambda do |*value|
|
808
831
|
image_proxy = ImageProxy.create(*value)
|
809
832
|
|
810
833
|
if image_proxy&.file_path&.end_with?('.gif')
|
@@ -845,7 +868,7 @@ module Glimmer
|
|
845
868
|
|
846
869
|
image_proxy&.swt_image
|
847
870
|
end,
|
848
|
-
:
|
871
|
+
cursor: lambda do |value|
|
849
872
|
cursor_proxy = nil
|
850
873
|
if value.is_a?(CursorProxy)
|
851
874
|
cursor_proxy = value
|
@@ -857,9 +880,9 @@ module Glimmer
|
|
857
880
|
:enabled => lambda do |value|
|
858
881
|
!!value
|
859
882
|
end,
|
860
|
-
:
|
861
|
-
:
|
862
|
-
:
|
883
|
+
foreground: color_converter,
|
884
|
+
link_foreground: color_converter,
|
885
|
+
font: lambda do |value|
|
863
886
|
if value.is_a?(Hash)
|
864
887
|
font_properties = value
|
865
888
|
FontProxy.new(self, font_properties).swt_font
|
@@ -867,21 +890,21 @@ module Glimmer
|
|
867
890
|
value
|
868
891
|
end
|
869
892
|
end,
|
870
|
-
:
|
893
|
+
image: lambda do |*value|
|
871
894
|
ImageProxy.create(*value).swt_image
|
872
895
|
end,
|
873
|
-
:
|
896
|
+
images: lambda do |array|
|
874
897
|
array.to_a.map do |value|
|
875
898
|
ImageProxy.create(value).swt_image
|
876
899
|
end.to_java(Image)
|
877
900
|
end,
|
878
|
-
:
|
901
|
+
items: lambda do |value|
|
879
902
|
value.to_java :string
|
880
903
|
end,
|
881
|
-
:
|
904
|
+
text: lambda do |value|
|
882
905
|
value.to_s
|
883
906
|
end,
|
884
|
-
:
|
907
|
+
transfer: lambda do |value|
|
885
908
|
value = value.first if value.is_a?(Array) && value.size == 1 && value.first.is_a?(Array)
|
886
909
|
transfer_object_extrapolator = lambda do |transfer_name|
|
887
910
|
transfer_type = "#{transfer_name.to_s.camelcase(:upper)}Transfer".to_sym
|
@@ -900,9 +923,12 @@ module Glimmer
|
|
900
923
|
result = result.to_java(Transfer) unless result.is_a?(ArrayJavaProxy)
|
901
924
|
result
|
902
925
|
end,
|
903
|
-
:
|
926
|
+
visible: lambda do |value|
|
904
927
|
!!value
|
905
928
|
end,
|
929
|
+
weights: lambda do |value|
|
930
|
+
value.to_java(:int)
|
931
|
+
end,
|
906
932
|
}
|
907
933
|
end
|
908
934
|
end
|