glimmer-dsl-swt 4.17.8.0 → 4.17.10.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -1
- data/README.md +289 -5
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +8 -3
- data/lib/glimmer-dsl-swt.rb +4 -3
- data/lib/glimmer/data_binding/table_items_binding.rb +5 -5
- data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +3 -3
- data/lib/glimmer/dsl/swt/directory_dialog_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/file_dialog_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +3 -3
- data/lib/glimmer/dsl/swt/shell_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +3 -3
- data/lib/glimmer/dsl/swt/widget_expression.rb +2 -1
- data/lib/glimmer/swt/custom/checkbox_group.rb +29 -8
- data/lib/glimmer/swt/custom/code_text.rb +47 -44
- data/lib/glimmer/swt/custom/radio_group.rb +27 -6
- data/lib/glimmer/swt/date_time_proxy.rb +87 -0
- data/lib/glimmer/swt/directory_dialog_proxy.rb +1 -1
- data/lib/glimmer/swt/display_proxy.rb +6 -6
- data/lib/glimmer/swt/dnd_proxy.rb +6 -10
- data/lib/glimmer/swt/file_dialog_proxy.rb +1 -1
- data/lib/glimmer/swt/menu_proxy.rb +1 -1
- data/lib/glimmer/swt/message_box_proxy.rb +7 -7
- data/lib/glimmer/swt/sash_form_proxy.rb +3 -3
- data/lib/glimmer/swt/shell_proxy.rb +19 -4
- data/lib/glimmer/swt/style_constantizable.rb +5 -5
- data/lib/glimmer/swt/swt_proxy.rb +7 -8
- data/lib/glimmer/swt/tab_item_proxy.rb +9 -4
- data/lib/glimmer/swt/table_column_proxy.rb +13 -5
- data/lib/glimmer/swt/table_proxy.rb +187 -66
- data/lib/glimmer/swt/widget_listener_proxy.rb +4 -4
- data/lib/glimmer/swt/widget_proxy.rb +48 -4
- data/lib/glimmer/ui/custom_shell.rb +1 -1
- data/samples/elaborate/contact_manager.rb +3 -3
- data/samples/elaborate/meta_sample.rb +9 -9
- data/samples/hello/hello_browser.rb +3 -3
- data/samples/hello/hello_checkbox.rb +4 -4
- data/samples/hello/hello_checkbox_group.rb +6 -3
- data/samples/hello/hello_combo.rb +5 -5
- data/samples/hello/hello_date_time.rb +63 -0
- data/samples/hello/hello_directory_dialog.rb +1 -1
- data/samples/hello/hello_file_dialog.rb +1 -1
- data/samples/hello/hello_group.rb +104 -0
- data/samples/hello/hello_menu_bar.rb +3 -3
- data/samples/hello/hello_pop_up_context_menu.rb +3 -3
- data/samples/hello/hello_radio.rb +6 -6
- data/samples/hello/hello_radio_group.rb +9 -6
- data/samples/hello/hello_sash_form.rb +3 -3
- data/samples/hello/hello_spinner.rb +69 -0
- data/samples/hello/hello_tab.rb +3 -3
- data/samples/hello/hello_table.rb +287 -0
- data/samples/hello/hello_world.rb +1 -1
- metadata +7 -2
data/lib/glimmer-dsl-swt.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2020 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
|
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
|
@@ -35,6 +35,7 @@ require 'logging'
|
|
35
35
|
require 'nested_inherited_jruby_include_package'
|
36
36
|
require 'super_module'
|
37
37
|
require 'rouge'
|
38
|
+
require 'date'
|
38
39
|
|
39
40
|
# Internal requires
|
40
41
|
require 'ext/glimmer/config'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2020 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
|
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
|
@@ -61,7 +61,7 @@ module Glimmer
|
|
61
61
|
add_dependent(@table_observer_registration => @table_items_observer_registration)
|
62
62
|
@model_collection = new_model_collection
|
63
63
|
end
|
64
|
-
populate_table(@model_collection, @table, @column_properties)
|
64
|
+
populate_table(@model_collection, @table, @column_properties)
|
65
65
|
end
|
66
66
|
|
67
67
|
def populate_table(model_collection, parent, column_properties)
|
@@ -79,7 +79,7 @@ module Glimmer
|
|
79
79
|
selected_table_items = parent.search {|item| selected_table_item_models.include?(item.getData) }
|
80
80
|
selected_table_items = [parent.swt_widget.getItems.first].to_java(TableItem) if selected_table_items.empty? && !parent.swt_widget.getItems.empty?
|
81
81
|
parent.swt_widget.setSelection(selected_table_items) unless selected_table_items.empty?
|
82
|
-
parent.sort
|
82
|
+
parent.sort!
|
83
83
|
parent.swt_widget.redraw if parent&.swt_widget&.respond_to?(:redraw)
|
84
84
|
end
|
85
85
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2020 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
|
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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2020 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
|
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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2020 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
|
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
|
@@ -57,4 +57,5 @@ require 'glimmer/swt/tree_proxy'
|
|
57
57
|
require 'glimmer/swt/table_proxy'
|
58
58
|
require 'glimmer/swt/table_column_proxy'
|
59
59
|
require 'glimmer/swt/sash_form_proxy'
|
60
|
-
require 'glimmer/swt/styled_text_proxy'
|
60
|
+
require 'glimmer/swt/styled_text_proxy'
|
61
|
+
require 'glimmer/swt/date_time_proxy'
|
@@ -1,9 +1,30 @@
|
|
1
|
+
# Copyright (c) 2007-2020 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
|
+
|
1
22
|
require 'glimmer/ui/custom_widget'
|
2
23
|
|
3
24
|
module Glimmer
|
4
25
|
module SWT
|
5
26
|
module Custom
|
6
|
-
#
|
27
|
+
# A custom widget rendering a group of checkboxes generated via data-binding
|
7
28
|
class CheckboxGroup
|
8
29
|
include Glimmer::UI::CustomWidget
|
9
30
|
|
@@ -71,7 +92,7 @@ module Glimmer
|
|
71
92
|
if observation_request != 'on_widget_disposed'
|
72
93
|
checkboxes.count.times do |index|
|
73
94
|
checkbox = checkboxes[index]
|
74
|
-
label = labels[index]
|
95
|
+
label = labels[index]
|
75
96
|
listener_block = lambda do |event|
|
76
97
|
event.widget = self.swt_widget
|
77
98
|
block.call(event)
|
@@ -81,7 +102,7 @@ module Glimmer
|
|
81
102
|
label.handle_observation_request('on_mouse_up', &listener_block)
|
82
103
|
else
|
83
104
|
checkbox.handle_observation_request(observation_request, &listener_block) if checkbox.can_handle_observation_request?(observation_request)
|
84
|
-
label.handle_observation_request(observation_request, &listener_block) if label.can_handle_observation_request?(observation_request)
|
105
|
+
label.handle_observation_request(observation_request, &listener_block) if label.can_handle_observation_request?(observation_request)
|
85
106
|
end
|
86
107
|
end
|
87
108
|
end
|
@@ -93,7 +114,7 @@ module Glimmer
|
|
93
114
|
|
94
115
|
def has_attribute?(attribute_name, *args)
|
95
116
|
(@composites.to_a + @checkboxes.to_a + @labels.to_a).map do |widget_proxy|
|
96
|
-
return true if widget_proxy.has_attribute?(attribute_name, *args)
|
117
|
+
return true if widget_proxy.has_attribute?(attribute_name, *args)
|
97
118
|
end
|
98
119
|
super
|
99
120
|
end
|
@@ -124,16 +145,16 @@ module Glimmer
|
|
124
145
|
margin_height 0
|
125
146
|
horizontal_spacing 0
|
126
147
|
vertical_spacing 0
|
127
|
-
}
|
148
|
+
}
|
128
149
|
checkboxes << checkbox { |checkbox_proxy|
|
129
|
-
on_widget_selected {
|
150
|
+
on_widget_selected {
|
130
151
|
self.selection_indices = checkboxes.each_with_index.map {|cb, i| i if cb.selection}.to_a.compact
|
131
152
|
}
|
132
153
|
}
|
133
154
|
labels << label { |label_proxy|
|
134
155
|
layout_data :fill, :center, true, false
|
135
156
|
text item
|
136
|
-
on_mouse_up { |event|
|
157
|
+
on_mouse_up { |event|
|
137
158
|
found_text = labels.each_with_index.detect {|l, i| event.widget == l.swt_widget}[0]&.text
|
138
159
|
selection_values = self.selection
|
139
160
|
if selection_values.include?(found_text)
|
@@ -148,7 +169,7 @@ module Glimmer
|
|
148
169
|
}
|
149
170
|
end
|
150
171
|
observation_requests.to_a.each do |observation_request, block|
|
151
|
-
delegate_observation_request_to_checkboxes(observation_request, &block)
|
172
|
+
delegate_observation_request_to_checkboxes(observation_request, &block)
|
152
173
|
end
|
153
174
|
self.selection = current_selection
|
154
175
|
end
|
@@ -8,20 +8,20 @@ module Glimmer
|
|
8
8
|
include Glimmer::UI::CustomWidget
|
9
9
|
|
10
10
|
SYNTAX_COLOR_MAP = {
|
11
|
-
Builtin: [215,58,73],
|
12
|
-
Class: [3,47,98],
|
13
|
-
Constant: [0,92,197],
|
11
|
+
Builtin: [215,58,73],
|
12
|
+
Class: [3,47,98],
|
13
|
+
Constant: [0,92,197],
|
14
14
|
Double: [0,92,197],
|
15
15
|
Escape: [:red],
|
16
|
-
Function: [:blue],
|
17
|
-
Instance: [227,98,9],
|
18
|
-
Integer: [:blue],
|
16
|
+
Function: [:blue],
|
17
|
+
Instance: [227,98,9],
|
18
|
+
Integer: [:blue],
|
19
19
|
Interpol: [:blue],
|
20
|
-
Keyword: [:blue],
|
20
|
+
Keyword: [:blue],
|
21
21
|
Name: [111,66,193], #purple
|
22
|
-
Operator: [:red],
|
22
|
+
Operator: [:red],
|
23
23
|
Pseudo: [:dark_red],
|
24
|
-
Punctuation: [:blue],
|
24
|
+
Punctuation: [:blue],
|
25
25
|
Single: [106,115,125], # Also, Comments
|
26
26
|
Symbol: [:dark_green],
|
27
27
|
Text: [75, 75, 75],
|
@@ -38,32 +38,25 @@ module Glimmer
|
|
38
38
|
swt_widget&.text
|
39
39
|
end
|
40
40
|
|
41
|
-
def syntax_highlighting
|
41
|
+
def syntax_highlighting(text)
|
42
42
|
return [] if text.to_s.strip.empty?
|
43
|
-
|
44
|
-
@
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
43
|
+
@syntax_highlighting ||= {}
|
44
|
+
unless @syntax_highlighting.keys.include?(text)
|
45
|
+
lex = lexer.lex(text).to_a
|
46
|
+
text_size = 0
|
47
|
+
@syntax_highlighting[text] = lex.map do |pair|
|
48
|
+
{token_type: pair.first, token_text: pair.last}
|
49
|
+
end.each do |hash|
|
50
|
+
hash[:token_index] = text_size
|
51
|
+
text_size += hash[:token_text].size
|
52
|
+
end
|
53
53
|
end
|
54
|
-
|
55
|
-
line_index = 0
|
56
|
-
@syntax_highlighting = text_lines_map = text_lines.reduce({}) do |hash, line|
|
57
|
-
line_hashes = []
|
58
|
-
line_hashes << lex_hashes.shift while lex_hashes.any? && lex_hashes.first[:token_index].between?(line_index, line_index + line.size)
|
59
|
-
hash.merge(line_index => line_hashes).tap do
|
60
|
-
line_index += line.size + 1
|
61
|
-
end
|
62
|
-
end
|
54
|
+
@syntax_highlighting[text]
|
63
55
|
end
|
64
56
|
|
65
|
-
def
|
66
|
-
|
57
|
+
def lexer
|
58
|
+
# TODO Try to use Rouge::Lexer.find_fancy('guess', code) in the future to guess the language or otherwise detect it from file extension
|
59
|
+
@lexer ||= Rouge::Lexer.find_fancy('ruby')
|
67
60
|
end
|
68
61
|
|
69
62
|
before_body {
|
@@ -78,22 +71,32 @@ module Glimmer
|
|
78
71
|
top_margin 5
|
79
72
|
right_margin 5
|
80
73
|
bottom_margin 5
|
74
|
+
|
75
|
+
on_modify_text { |event|
|
76
|
+
# clear unnecessary syntax highlighting cache on text updates, and do it async to avoid affecting performance
|
77
|
+
new_text = event.data
|
78
|
+
async_exec {
|
79
|
+
unless @syntax_highlighting.nil?
|
80
|
+
lines = new_text.to_s.split("\n")
|
81
|
+
line_diff = @syntax_highlighting.keys - lines
|
82
|
+
line_diff.each do |line|
|
83
|
+
@syntax_highlighting.delete(line)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
}
|
87
|
+
}
|
81
88
|
|
82
89
|
on_line_get_style { |line_style_event|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
token_color = color(*token_color).swt_color
|
91
|
-
styles << StyleRange.new(start_index, size, token_color, nil)
|
92
|
-
end
|
93
|
-
@styles[line_style_event.lineOffset] = styles.to_java(StyleRange)
|
90
|
+
styles = []
|
91
|
+
syntax_highlighting(line_style_event.lineText).to_a.each do |token_hash|
|
92
|
+
start_index = token_hash[:token_index]
|
93
|
+
size = token_hash[:token_text].size
|
94
|
+
token_color = SYNTAX_COLOR_MAP[token_hash[:token_type].name] || [:black]
|
95
|
+
token_color = color(*token_color).swt_color
|
96
|
+
styles << StyleRange.new(line_style_event.lineOffset + start_index, size, token_color, nil)
|
94
97
|
end
|
95
|
-
line_style_event.styles =
|
96
|
-
}
|
98
|
+
line_style_event.styles = styles.to_java(StyleRange) unless styles.empty?
|
99
|
+
}
|
97
100
|
}
|
98
101
|
}
|
99
102
|
end
|
@@ -1,9 +1,30 @@
|
|
1
|
+
# Copyright (c) 2007-2020 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
|
+
|
1
22
|
require 'glimmer/ui/custom_widget'
|
2
23
|
|
3
24
|
module Glimmer
|
4
25
|
module SWT
|
5
26
|
module Custom
|
6
|
-
#
|
27
|
+
# A custom widget rendering a group of radios generated via data-binding
|
7
28
|
class RadioGroup
|
8
29
|
include Glimmer::UI::CustomWidget
|
9
30
|
|
@@ -65,7 +86,7 @@ module Glimmer
|
|
65
86
|
if observation_request != 'on_widget_disposed'
|
66
87
|
radios.count.times do |index|
|
67
88
|
radio = radios[index]
|
68
|
-
label = labels[index]
|
89
|
+
label = labels[index]
|
69
90
|
if observation_request == 'on_widget_selected'
|
70
91
|
radio_block = lambda do |event|
|
71
92
|
if event.widget.selection || selection_index == -1
|
@@ -76,7 +97,7 @@ module Glimmer
|
|
76
97
|
label_block = lambda do |event|
|
77
98
|
self.selection_index = index
|
78
99
|
block.call(event)
|
79
|
-
end
|
100
|
+
end
|
80
101
|
radio.handle_observation_request(observation_request, &radio_block) if radio.can_handle_observation_request?(observation_request)
|
81
102
|
label.handle_observation_request('on_mouse_up', &label_block)
|
82
103
|
else
|
@@ -85,7 +106,7 @@ module Glimmer
|
|
85
106
|
block.call(event)
|
86
107
|
end
|
87
108
|
radio.handle_observation_request(observation_request, &listener_block) if radio.can_handle_observation_request?(observation_request)
|
88
|
-
label.handle_observation_request(observation_request, &listener_block) if label.can_handle_observation_request?(observation_request)
|
109
|
+
label.handle_observation_request(observation_request, &listener_block) if label.can_handle_observation_request?(observation_request)
|
89
110
|
end
|
90
111
|
end
|
91
112
|
end
|
@@ -97,7 +118,7 @@ module Glimmer
|
|
97
118
|
|
98
119
|
def has_attribute?(attribute_name, *args)
|
99
120
|
(@composites.to_a + @radios.to_a + @labels.to_a).map do |widget_proxy|
|
100
|
-
return true if widget_proxy.has_attribute?(attribute_name, *args)
|
121
|
+
return true if widget_proxy.has_attribute?(attribute_name, *args)
|
101
122
|
end
|
102
123
|
super
|
103
124
|
end
|
@@ -145,7 +166,7 @@ module Glimmer
|
|
145
166
|
}
|
146
167
|
end
|
147
168
|
observation_requests.to_a.each do |observation_request, block|
|
148
|
-
delegate_observation_request_to_radios(observation_request, &block)
|
169
|
+
delegate_observation_request_to_radios(observation_request, &block)
|
149
170
|
end
|
150
171
|
self.selection = current_selection
|
151
172
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Copyright (c) 2007-2020 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
|
+
require 'date'
|
23
|
+
require 'glimmer/swt/widget_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module SWT
|
27
|
+
# Proxy for org.eclipse.swt.widgets.DateTime
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class DateTimeProxy < WidgetProxy
|
31
|
+
CUSTOM_ATTRIBUTES = %w[date_time date time month]
|
32
|
+
|
33
|
+
def date_time
|
34
|
+
DateTime.new(year, month, day, hours, minutes, seconds)
|
35
|
+
end
|
36
|
+
|
37
|
+
def date_time=(date_time_value)
|
38
|
+
self.time = date_time_value.to_time
|
39
|
+
end
|
40
|
+
|
41
|
+
def date
|
42
|
+
date_time.to_date
|
43
|
+
end
|
44
|
+
|
45
|
+
def date=(date_value)
|
46
|
+
self.year = date_value.year
|
47
|
+
self.month = date_value.month
|
48
|
+
self.day = date_value.day
|
49
|
+
end
|
50
|
+
|
51
|
+
def time
|
52
|
+
date_time.to_time
|
53
|
+
end
|
54
|
+
|
55
|
+
def time=(time_value)
|
56
|
+
self.date = time_value.to_date
|
57
|
+
self.hours = time_value.hour
|
58
|
+
self.minutes = time_value.min
|
59
|
+
self.seconds = time_value.sec
|
60
|
+
end
|
61
|
+
|
62
|
+
def month
|
63
|
+
swt_widget.month + 1
|
64
|
+
end
|
65
|
+
|
66
|
+
def month=(new_value)
|
67
|
+
swt_widget.month = new_value - 1
|
68
|
+
end
|
69
|
+
|
70
|
+
def set_attribute(attribute_name, *args)
|
71
|
+
if CUSTOM_ATTRIBUTES.include?(attribute_name.to_s)
|
72
|
+
send(ruby_attribute_setter(attribute_name), args.first)
|
73
|
+
else
|
74
|
+
super(attribute_name, *args)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def get_attribute(attribute_name)
|
79
|
+
if CUSTOM_ATTRIBUTES.include?(attribute_name.to_s)
|
80
|
+
send(attribute_name)
|
81
|
+
else
|
82
|
+
super(attribute_name)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|