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
@@ -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
|
@@ -59,7 +59,7 @@ module Glimmer
|
|
59
59
|
|
60
60
|
def content(&block)
|
61
61
|
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::DisplayExpression.new, &block)
|
62
|
-
end
|
62
|
+
end
|
63
63
|
|
64
64
|
def method_missing(method, *args, &block)
|
65
65
|
if can_handle_observation_request?(method)
|
@@ -73,8 +73,8 @@ module Glimmer
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def respond_to?(method, *args, &block)
|
76
|
-
super ||
|
77
|
-
can_handle_observation_request?(method) ||
|
76
|
+
super ||
|
77
|
+
can_handle_observation_request?(method) ||
|
78
78
|
swt_display.respond_to?(method, *args, &block)
|
79
79
|
end
|
80
80
|
|
@@ -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
|
@@ -26,15 +26,15 @@ module Glimmer
|
|
26
26
|
# Proxy for org.eclipse.swt.dnd.DND
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
|
-
class DNDProxy
|
30
|
-
include StyleConstantizable
|
29
|
+
class DNDProxy
|
30
|
+
include StyleConstantizable
|
31
31
|
|
32
32
|
class << self
|
33
33
|
JAVA_IMPORT = 'org.eclipse.swt.dnd.DND'
|
34
34
|
|
35
35
|
java_import JAVA_IMPORT
|
36
36
|
|
37
|
-
def constant_java_import
|
37
|
+
def constant_java_import
|
38
38
|
JAVA_IMPORT
|
39
39
|
end
|
40
40
|
|
@@ -45,10 +45,6 @@ module Glimmer
|
|
45
45
|
def constant_value_none
|
46
46
|
DND::DROP_NONE
|
47
47
|
end
|
48
|
-
|
49
|
-
def extra_styles
|
50
|
-
{}
|
51
|
-
end
|
52
48
|
end
|
53
49
|
end
|
54
50
|
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
|
@@ -38,7 +38,7 @@ module Glimmer
|
|
38
38
|
if parent.nil?
|
39
39
|
@temporary_parent = parent = Glimmer::SWT::ShellProxy.new.swt_widget
|
40
40
|
end
|
41
|
-
@swt_widget = MessageBox.new(parent, style)
|
41
|
+
@swt_widget = MessageBox.new(parent, style)
|
42
42
|
end
|
43
43
|
|
44
44
|
def open
|
@@ -49,7 +49,7 @@ module Glimmer
|
|
49
49
|
|
50
50
|
def content(&block)
|
51
51
|
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::MessageBoxExpression.new, &block)
|
52
|
-
end
|
52
|
+
end
|
53
53
|
|
54
54
|
# TODO refactor the following methods to put in a JavaBean mixin or somethin (perhaps contribute to OSS project too)
|
55
55
|
|
@@ -81,9 +81,9 @@ module Glimmer
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def respond_to?(method, *args, &block)
|
84
|
-
super ||
|
84
|
+
super ||
|
85
85
|
swt_widget.respond_to?(method, *args, &block)
|
86
|
-
end
|
86
|
+
end
|
87
87
|
end
|
88
88
|
end
|
89
89
|
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
|
@@ -88,18 +88,26 @@ module Glimmer
|
|
88
88
|
|
89
89
|
# Opens shell and starts SWT's UI thread event loop
|
90
90
|
def open
|
91
|
+
open_only
|
92
|
+
start_event_loop unless nested?
|
93
|
+
end
|
94
|
+
alias show open
|
95
|
+
|
96
|
+
# Opens without starting the event loop.
|
97
|
+
def open_only
|
91
98
|
if @opened_before
|
92
99
|
@swt_widget.setVisible(true)
|
93
|
-
# notify_observers('visible')
|
94
100
|
else
|
95
101
|
@opened_before = true
|
96
102
|
@swt_widget.pack
|
97
103
|
center
|
98
104
|
@swt_widget.open
|
99
|
-
start_event_loop
|
100
105
|
end
|
101
106
|
end
|
102
|
-
|
107
|
+
|
108
|
+
def nested?
|
109
|
+
!parent.nil?
|
110
|
+
end
|
103
111
|
|
104
112
|
def hide
|
105
113
|
@swt_widget.setVisible(false)
|
@@ -113,6 +121,10 @@ module Glimmer
|
|
113
121
|
def visible=(visibility)
|
114
122
|
visibility ? show : hide
|
115
123
|
end
|
124
|
+
|
125
|
+
def include_focus_control?
|
126
|
+
DisplayProxy.instance.focus_control&.shell == swt_widget
|
127
|
+
end
|
116
128
|
|
117
129
|
def pack
|
118
130
|
@swt_widget.pack
|
@@ -169,6 +181,9 @@ module Glimmer
|
|
169
181
|
super
|
170
182
|
end
|
171
183
|
end
|
184
|
+
|
172
185
|
end
|
186
|
+
|
173
187
|
end
|
174
|
-
|
188
|
+
|
189
|
+
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
|
@@ -43,9 +43,9 @@ module Glimmer
|
|
43
43
|
raise 'Not implemented! Mixer must implement!'
|
44
44
|
end
|
45
45
|
|
46
|
-
# hash of extra styles (i.e. new style
|
46
|
+
# hash of extra composite styles (i.e. style combinations defined under new style names)
|
47
47
|
def extra_styles
|
48
|
-
|
48
|
+
{}
|
49
49
|
end
|
50
50
|
|
51
51
|
def error_message_invalid_style
|
@@ -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
|
@@ -26,15 +26,15 @@ module Glimmer
|
|
26
26
|
# Proxy for org.eclipse.swt.SWT
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
|
-
class SWTProxy
|
30
|
-
include StyleConstantizable
|
29
|
+
class SWTProxy
|
30
|
+
include StyleConstantizable
|
31
31
|
|
32
32
|
class << self
|
33
33
|
JAVA_IMPORT = 'org.eclipse.swt.SWT'
|
34
34
|
|
35
35
|
java_import JAVA_IMPORT
|
36
36
|
|
37
|
-
def constant_java_import
|
37
|
+
def constant_java_import
|
38
38
|
JAVA_IMPORT
|
39
39
|
end
|
40
40
|
|
@@ -53,8 +53,7 @@ module Glimmer
|
|
53
53
|
|
54
54
|
EXTRA_STYLES = {
|
55
55
|
NO_RESIZE: self[:shell_trim, :resize!, :max!],
|
56
|
-
|
57
|
-
}
|
56
|
+
}
|
58
57
|
end
|
59
58
|
end
|
60
59
|
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
|
@@ -39,6 +39,7 @@ module Glimmer
|
|
39
39
|
#
|
40
40
|
# Follows the Proxy Design Pattern
|
41
41
|
class TabItemProxy < WidgetProxy
|
42
|
+
ATTRIBUTES = %w[text image]
|
42
43
|
include_package 'org.eclipse.swt.widgets'
|
43
44
|
|
44
45
|
attr_reader :widget_proxy, :swt_tab_item
|
@@ -51,7 +52,7 @@ module Glimmer
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def has_attribute?(attribute_name, *args)
|
54
|
-
if attribute_name.to_s
|
55
|
+
if ATTRIBUTES.include?(attribute_name.to_s)
|
55
56
|
true
|
56
57
|
else
|
57
58
|
super(attribute_name, *args)
|
@@ -63,6 +64,8 @@ module Glimmer
|
|
63
64
|
if attribute_name.to_s == "text"
|
64
65
|
text_value = args[0]
|
65
66
|
@swt_tab_item.setText text_value
|
67
|
+
elsif attribute_name.to_s == "image"
|
68
|
+
widget_proxy.set_attribute('image', *args)
|
66
69
|
else
|
67
70
|
super(attribute_name, *args)
|
68
71
|
end
|
@@ -71,6 +74,8 @@ module Glimmer
|
|
71
74
|
def get_attribute(attribute_name)
|
72
75
|
if attribute_name.to_s == "text"
|
73
76
|
@swt_tab_item.getText
|
77
|
+
elsif attribute_name.to_s == "image"
|
78
|
+
widget_proxy.get_attribute('image')
|
74
79
|
else
|
75
80
|
super(attribute_name)
|
76
81
|
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
|
@@ -20,10 +20,13 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
require 'glimmer/swt/widget_proxy'
|
23
|
+
require 'glimmer/swt/swt_proxy'
|
23
24
|
|
24
25
|
module Glimmer
|
25
26
|
module SWT
|
26
|
-
|
27
|
+
# A proxy object representing SWT TableColumn
|
28
|
+
# Accepts a :no_sort custom style to disable sorting on this column
|
29
|
+
class TableColumnProxy < Glimmer::SWT::WidgetProxy
|
27
30
|
attr_reader :no_sort, :sort_property, :editor
|
28
31
|
alias no_sort? no_sort
|
29
32
|
attr_accessor :sort_block, :sort_by_block
|
@@ -32,7 +35,7 @@ module Glimmer
|
|
32
35
|
@no_sort = args.delete(:no_sort)
|
33
36
|
super
|
34
37
|
on_widget_selected do |event|
|
35
|
-
parent.sort_by_column(self)
|
38
|
+
parent.sort_by_column!(self)
|
36
39
|
end unless no_sort?
|
37
40
|
end
|
38
41
|
|
@@ -40,10 +43,15 @@ module Glimmer
|
|
40
43
|
@sort_property = args unless args.empty?
|
41
44
|
end
|
42
45
|
|
46
|
+
# Sets editor (e.g. combo)
|
43
47
|
def editor=(args)
|
44
48
|
@editor = args
|
45
49
|
end
|
46
50
|
|
51
|
+
def editable?
|
52
|
+
!@editor&.include?(:none)
|
53
|
+
end
|
54
|
+
|
47
55
|
end
|
48
56
|
end
|
49
57
|
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
|
@@ -26,14 +26,14 @@ module Glimmer
|
|
26
26
|
class TableProxy < Glimmer::SWT::WidgetProxy
|
27
27
|
include Glimmer
|
28
28
|
|
29
|
-
module TableListenerEvent
|
29
|
+
module TableListenerEvent
|
30
30
|
def table_item
|
31
31
|
table_item_and_column_index[:table_item]
|
32
32
|
end
|
33
33
|
|
34
34
|
def column_index
|
35
35
|
table_item_and_column_index[:column_index]
|
36
|
-
end
|
36
|
+
end
|
37
37
|
|
38
38
|
private
|
39
39
|
|
@@ -51,7 +51,7 @@ module Glimmer
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
|
-
end
|
54
|
+
end
|
55
55
|
end
|
56
56
|
|
57
57
|
class << self
|
@@ -74,9 +74,9 @@ module Glimmer
|
|
74
74
|
elsif key_event.keyCode == swt(:esc)
|
75
75
|
table_proxy.cancel_edit!
|
76
76
|
end
|
77
|
-
}
|
77
|
+
}
|
78
78
|
}
|
79
|
-
table_editor_widget_proxy.swt_widget.selectAll
|
79
|
+
table_editor_widget_proxy.swt_widget.selectAll
|
80
80
|
table_editor_widget_proxy
|
81
81
|
end,
|
82
82
|
},
|
@@ -101,8 +101,8 @@ module Glimmer
|
|
101
101
|
}
|
102
102
|
on_widget_selected {
|
103
103
|
if !OS.windows? || !first_time || first_time && model.send(property) != table_editor_widget_proxy.swt_widget.text
|
104
|
-
table_proxy.finish_edit!
|
105
|
-
end
|
104
|
+
table_proxy.finish_edit!
|
105
|
+
end
|
106
106
|
}
|
107
107
|
}
|
108
108
|
table_editor_widget_proxy
|
@@ -117,10 +117,73 @@ module Glimmer
|
|
117
117
|
selection model.send(property)
|
118
118
|
focus true
|
119
119
|
on_widget_selected {
|
120
|
-
table_proxy.finish_edit!
|
120
|
+
table_proxy.finish_edit!
|
121
|
+
}
|
122
|
+
on_focus_lost {
|
123
|
+
table_proxy.finish_edit!
|
124
|
+
}
|
125
|
+
on_key_pressed { |key_event|
|
126
|
+
if key_event.keyCode == swt(:cr)
|
127
|
+
table_proxy.finish_edit!
|
128
|
+
elsif key_event.keyCode == swt(:esc)
|
129
|
+
table_proxy.cancel_edit!
|
130
|
+
end
|
131
|
+
}
|
132
|
+
}
|
133
|
+
end,
|
134
|
+
},
|
135
|
+
date: {
|
136
|
+
widget_value_property: :date_time,
|
137
|
+
editor_gui: lambda do |args, model, property, table_proxy|
|
138
|
+
first_time = true
|
139
|
+
table_proxy.table_editor.minimumHeight = 25
|
140
|
+
date(*args) {
|
141
|
+
date_time model.send(property)
|
142
|
+
focus true
|
143
|
+
on_focus_lost {
|
144
|
+
table_proxy.finish_edit!
|
145
|
+
}
|
146
|
+
on_key_pressed { |key_event|
|
147
|
+
if key_event.keyCode == swt(:cr)
|
148
|
+
table_proxy.finish_edit!
|
149
|
+
elsif key_event.keyCode == swt(:esc)
|
150
|
+
table_proxy.cancel_edit!
|
151
|
+
end
|
152
|
+
}
|
153
|
+
}
|
154
|
+
end,
|
155
|
+
},
|
156
|
+
date_drop_down: {
|
157
|
+
widget_value_property: :date_time,
|
158
|
+
editor_gui: lambda do |args, model, property, table_proxy|
|
159
|
+
first_time = true
|
160
|
+
table_proxy.table_editor.minimumHeight = 25
|
161
|
+
date_drop_down(*args) {
|
162
|
+
date_time model.send(property)
|
163
|
+
focus true
|
164
|
+
on_focus_lost {
|
165
|
+
table_proxy.finish_edit!
|
121
166
|
}
|
167
|
+
on_key_pressed { |key_event|
|
168
|
+
if key_event.keyCode == swt(:cr)
|
169
|
+
table_proxy.finish_edit!
|
170
|
+
elsif key_event.keyCode == swt(:esc)
|
171
|
+
table_proxy.cancel_edit!
|
172
|
+
end
|
173
|
+
}
|
174
|
+
}
|
175
|
+
end,
|
176
|
+
},
|
177
|
+
time: {
|
178
|
+
widget_value_property: :date_time,
|
179
|
+
editor_gui: lambda do |args, model, property, table_proxy|
|
180
|
+
first_time = true
|
181
|
+
table_proxy.table_editor.minimumHeight = 25
|
182
|
+
time(*args) {
|
183
|
+
date_time model.send(property)
|
184
|
+
focus true
|
122
185
|
on_focus_lost {
|
123
|
-
table_proxy.finish_edit!
|
186
|
+
table_proxy.finish_edit!
|
124
187
|
}
|
125
188
|
on_key_pressed { |key_event|
|
126
189
|
if key_event.keyCode == swt(:cr)
|
@@ -128,7 +191,7 @@ module Glimmer
|
|
128
191
|
elsif key_event.keyCode == swt(:esc)
|
129
192
|
table_proxy.cancel_edit!
|
130
193
|
end
|
131
|
-
}
|
194
|
+
}
|
132
195
|
}
|
133
196
|
end,
|
134
197
|
},
|
@@ -141,10 +204,10 @@ module Glimmer
|
|
141
204
|
selection model.send(property)
|
142
205
|
focus true
|
143
206
|
on_widget_selected {
|
144
|
-
table_proxy.finish_edit!
|
207
|
+
table_proxy.finish_edit!
|
145
208
|
}
|
146
209
|
on_focus_lost {
|
147
|
-
table_proxy.finish_edit!
|
210
|
+
table_proxy.finish_edit!
|
148
211
|
}
|
149
212
|
on_key_pressed { |key_event|
|
150
213
|
if key_event.keyCode == swt(:cr)
|
@@ -152,33 +215,103 @@ module Glimmer
|
|
152
215
|
elsif key_event.keyCode == swt(:esc)
|
153
216
|
table_proxy.cancel_edit!
|
154
217
|
end
|
155
|
-
}
|
218
|
+
}
|
156
219
|
}
|
157
220
|
end,
|
158
|
-
}
|
159
|
-
|
221
|
+
},
|
222
|
+
spinner: {
|
223
|
+
widget_value_property: :selection,
|
224
|
+
editor_gui: lambda do |args, model, property, table_proxy|
|
225
|
+
first_time = true
|
226
|
+
table_proxy.table_editor.minimumHeight = 25
|
227
|
+
table_editor_widget_proxy = spinner(*args) {
|
228
|
+
selection model.send(property)
|
229
|
+
focus true
|
230
|
+
on_focus_lost {
|
231
|
+
table_proxy.finish_edit!
|
232
|
+
}
|
233
|
+
on_key_pressed { |key_event|
|
234
|
+
if key_event.keyCode == swt(:cr)
|
235
|
+
table_proxy.finish_edit!
|
236
|
+
elsif key_event.keyCode == swt(:esc)
|
237
|
+
table_proxy.cancel_edit!
|
238
|
+
end
|
239
|
+
}
|
240
|
+
}
|
241
|
+
table_editor_widget_proxy
|
242
|
+
end,
|
243
|
+
},
|
244
|
+
}
|
160
245
|
end
|
161
246
|
end
|
162
247
|
|
163
|
-
attr_reader :table_editor, :table_editor_widget_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block, :additional_sort_properties, :editor
|
248
|
+
attr_reader :table_editor, :table_editor_widget_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block, :additional_sort_properties, :editor, :editable, :initial_sort_property
|
164
249
|
attr_accessor :column_properties
|
250
|
+
alias editable? editable
|
165
251
|
|
166
252
|
def initialize(underscored_widget_name, parent, args)
|
253
|
+
@editable = args.delete(:editable)
|
167
254
|
super
|
168
255
|
@table_editor = TableEditor.new(swt_widget)
|
169
256
|
@table_editor.horizontalAlignment = SWTProxy[:left]
|
170
257
|
@table_editor.grabHorizontal = true
|
171
258
|
@table_editor.minimumHeight = 20
|
259
|
+
if editable?
|
260
|
+
content {
|
261
|
+
on_mouse_up { |event|
|
262
|
+
edit_table_item(event.table_item, event.column_index)
|
263
|
+
}
|
264
|
+
}
|
265
|
+
end
|
172
266
|
end
|
173
267
|
|
174
268
|
def model_binding
|
175
269
|
swt_widget.data
|
176
270
|
end
|
177
271
|
|
178
|
-
def
|
179
|
-
|
180
|
-
|
181
|
-
|
272
|
+
def sort_block=(comparator)
|
273
|
+
@sort_block = comparator
|
274
|
+
end
|
275
|
+
|
276
|
+
def sort_by_block=(property_picker)
|
277
|
+
@sort_by_block = property_picker
|
278
|
+
end
|
279
|
+
|
280
|
+
def sort_property=(new_sort_property)
|
281
|
+
@sort_property = [new_sort_property].flatten.compact
|
282
|
+
end
|
283
|
+
|
284
|
+
def detect_sort_type
|
285
|
+
@sort_type = sort_property.size.times.map { String }
|
286
|
+
array = model_binding.evaluate_property
|
287
|
+
sort_property.each_with_index do |a_sort_property, i|
|
288
|
+
values = array.map { |object| object.send(a_sort_property) }
|
289
|
+
value_classes = values.map(&:class).uniq
|
290
|
+
if value_classes.size == 1
|
291
|
+
@sort_type[i] = value_classes.first
|
292
|
+
elsif value_classes.include?(Integer)
|
293
|
+
@sort_type[i] = Integer
|
294
|
+
elsif value_classes.include?(Float)
|
295
|
+
@sort_type[i] = Float
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
def column_sort_properties
|
301
|
+
column_properties.zip(table_column_proxies.map(&:sort_property)).map do |pair|
|
302
|
+
[pair.compact.last].flatten.compact
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
# Sorts by specified TableColumnProxy object. If nil, it uses the table default sort instead.
|
307
|
+
def sort_by_column!(table_column_proxy=nil)
|
308
|
+
index = swt_widget.columns.to_a.index(table_column_proxy.swt_widget) unless table_column_proxy.nil?
|
309
|
+
new_sort_property = table_column_proxy.nil? ? @sort_property : table_column_proxy.sort_property || [column_properties[index]]
|
310
|
+
return if table_column_proxy.nil? && new_sort_property.nil? && @sort_block.nil? && @sort_by_block.nil?
|
311
|
+
if new_sort_property && table_column_proxy.nil? && new_sort_property.size == 1 && (index = column_sort_properties.index(new_sort_property))
|
312
|
+
table_column_proxy = table_column_proxies[index]
|
313
|
+
end
|
314
|
+
if new_sort_property && new_sort_property.size == 1 && !additional_sort_properties.to_a.empty?
|
182
315
|
selected_additional_sort_properties = additional_sort_properties.clone
|
183
316
|
if selected_additional_sort_properties.include?(new_sort_property.first)
|
184
317
|
selected_additional_sort_properties.delete(new_sort_property.first)
|
@@ -188,39 +321,32 @@ module Glimmer
|
|
188
321
|
end
|
189
322
|
end
|
190
323
|
|
191
|
-
@sort_direction = @sort_direction.nil? || @sort_property != new_sort_property || @sort_direction == :descending ? :ascending : :descending
|
324
|
+
@sort_direction = @sort_direction.nil? || @sort_property.first != new_sort_property.first || @sort_direction == :descending ? :ascending : :descending
|
192
325
|
swt_widget.sort_direction = @sort_direction == :ascending ? SWTProxy[:up] : SWTProxy[:down]
|
193
326
|
|
194
|
-
@sort_property = new_sort_property
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
327
|
+
@sort_property = [new_sort_property].flatten.compact
|
328
|
+
table_column_index = column_properties.index(new_sort_property.to_s.to_sym)
|
329
|
+
table_column_proxy ||= table_column_proxies[table_column_index] if table_column_index
|
330
|
+
swt_widget.sort_column = table_column_proxy.swt_widget if table_column_proxy
|
331
|
+
|
332
|
+
if table_column_proxy
|
333
|
+
@sort_by_block = nil
|
334
|
+
@sort_block = nil
|
335
|
+
end
|
199
336
|
@sort_type = nil
|
200
|
-
if table_column_proxy
|
337
|
+
if table_column_proxy&.sort_by_block
|
201
338
|
@sort_by_block = table_column_proxy.sort_by_block
|
202
|
-
elsif table_column_proxy
|
339
|
+
elsif table_column_proxy&.sort_block
|
203
340
|
@sort_block = table_column_proxy.sort_block
|
204
341
|
else
|
205
|
-
detect_sort_type
|
342
|
+
detect_sort_type
|
206
343
|
end
|
207
|
-
|
344
|
+
|
345
|
+
sort!
|
208
346
|
end
|
209
347
|
|
210
|
-
def
|
211
|
-
|
212
|
-
array = model_binding.evaluate_property
|
213
|
-
sort_property.each_with_index do |a_sort_property, i|
|
214
|
-
values = array.map { |object| object.send(a_sort_property) }
|
215
|
-
value_classes = values.map(&:class).uniq
|
216
|
-
if value_classes.size == 1
|
217
|
-
@sort_type[i] = value_classes.first
|
218
|
-
elsif value_classes.include?(Integer)
|
219
|
-
@sort_type[i] = Integer
|
220
|
-
elsif value_classes.include?(Float)
|
221
|
-
@sort_type[i] = Float
|
222
|
-
end
|
223
|
-
end
|
348
|
+
def initial_sort!
|
349
|
+
sort_by_column!
|
224
350
|
end
|
225
351
|
|
226
352
|
def additional_sort_properties=(args)
|
@@ -229,7 +355,7 @@ module Glimmer
|
|
229
355
|
|
230
356
|
def editor=(args)
|
231
357
|
@editor = args
|
232
|
-
end
|
358
|
+
end
|
233
359
|
|
234
360
|
def cells_for(model)
|
235
361
|
column_properties.map {|property| model.send(property)}
|
@@ -240,7 +366,7 @@ module Glimmer
|
|
240
366
|
swt_widget.items.map {|item| column_count.times.map {|i| item.get_text(i)} }
|
241
367
|
end
|
242
368
|
|
243
|
-
def sort
|
369
|
+
def sort!
|
244
370
|
return unless sort_property && (sort_type || sort_block || sort_by_block)
|
245
371
|
array = model_binding.evaluate_property
|
246
372
|
array = array.sort_by(&:hash) # this ensures consistent subsequent sorting in case there are equivalent sorts to avoid an infinite loop
|
@@ -248,7 +374,7 @@ module Glimmer
|
|
248
374
|
if sort_block
|
249
375
|
sorted_array = array.sort(&sort_block)
|
250
376
|
elsif sort_by_block
|
251
|
-
sorted_array = array.sort_by(&sort_by_block)
|
377
|
+
sorted_array = array.sort_by(&sort_by_block)
|
252
378
|
else
|
253
379
|
sorted_array = array.sort_by do |object|
|
254
380
|
sort_property.each_with_index.map do |a_sort_property, i|
|
@@ -281,22 +407,16 @@ module Glimmer
|
|
281
407
|
search
|
282
408
|
end
|
283
409
|
|
284
|
-
def widget_property_listener_installers
|
285
|
-
super.merge({
|
286
|
-
Java::OrgEclipseSwtWidgets::Table => {
|
287
|
-
selection: lambda do |observer|
|
288
|
-
on_widget_selected { |selection_event|
|
289
|
-
observer.call(@swt_widget.getSelection)
|
290
|
-
}
|
291
|
-
end
|
292
|
-
},
|
293
|
-
})
|
294
|
-
end
|
295
|
-
|
296
410
|
def post_initialize_child(table_column_proxy)
|
297
411
|
table_column_proxies << table_column_proxy
|
298
412
|
end
|
299
413
|
|
414
|
+
def post_add_content
|
415
|
+
return if @initially_sorted
|
416
|
+
initial_sort!
|
417
|
+
@initially_sorted = true
|
418
|
+
end
|
419
|
+
|
300
420
|
def table_column_proxies
|
301
421
|
@table_column_proxies ||= []
|
302
422
|
end
|
@@ -329,7 +449,8 @@ module Glimmer
|
|
329
449
|
return if table_item.nil?
|
330
450
|
model = table_item.data
|
331
451
|
property = column_properties[column_index]
|
332
|
-
|
452
|
+
cancel_edit!
|
453
|
+
return unless table_column_proxies[column_index].editable?
|
333
454
|
action_taken = false
|
334
455
|
@edit_mode = true
|
335
456
|
|
@@ -354,7 +475,7 @@ module Glimmer
|
|
354
475
|
end
|
355
476
|
|
356
477
|
@finish_edit = lambda do |event=nil|
|
357
|
-
new_value = @table_editor_widget_proxy&.
|
478
|
+
new_value = @table_editor_widget_proxy&.send(widget_value_property)
|
358
479
|
if table_item.isDisposed
|
359
480
|
@cancel_edit.call
|
360
481
|
elsif !new_value.nil? && !action_taken && !@edit_in_progress && !@cancel_in_progress
|
@@ -370,13 +491,13 @@ module Glimmer
|
|
370
491
|
swt_widget.showItem(edited_table_item)
|
371
492
|
@table_editor_widget_proxy&.swt_widget&.dispose
|
372
493
|
@table_editor_widget_proxy = nil
|
373
|
-
after_write&.call(edited_table_item)
|
494
|
+
after_write&.call(edited_table_item)
|
374
495
|
@edit_in_progress = false
|
375
496
|
end
|
376
497
|
end
|
377
498
|
end
|
378
499
|
|
379
|
-
content {
|
500
|
+
content {
|
380
501
|
@table_editor_widget_proxy = TableProxy::editors.symbolize_keys[editor_widget][:editor_gui].call(editor_widget_args, model, model_editing_property, self)
|
381
502
|
}
|
382
503
|
@table_editor.setEditor(@table_editor_widget_proxy.swt_widget, table_item, column_index)
|