glimmer-dsl-opal 0.10.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +84 -22
- data/VERSION +1 -1
- data/lib/display.rb +3 -0
- data/lib/glimmer-dsl-opal.rb +1 -1
- data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +5 -2
- data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +17 -13
- data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +55 -28
- data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +2 -2
- data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +4 -4
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +5 -5
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +4 -4
- data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +6 -6
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +6 -6
- data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +2 -2
- data/lib/glimmer/data_binding/table_items_binding.rb +3 -2
- data/lib/glimmer/dsl/opal/bind_expression.rb +24 -25
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +6 -6
- data/lib/glimmer/dsl/opal/dsl.rb +4 -0
- data/lib/glimmer/dsl/opal/menu_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/message_box_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/property_expression.rb +2 -1
- data/lib/glimmer/dsl/opal/shape_expression.rb +26 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/shine_data_binding_expression.rb +49 -0
- data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/widget_expression.rb +1 -1
- data/lib/glimmer/swt/combo_proxy.rb +1 -0
- data/lib/glimmer/swt/composite_proxy.rb +18 -2
- data/lib/glimmer/swt/dialog_proxy.rb +47 -32
- data/lib/glimmer/swt/display_proxy.rb +128 -9
- data/lib/glimmer/swt/grid_layout_proxy.rb +28 -33
- data/lib/glimmer/swt/latest_dialog_proxy.rb +3 -1
- data/lib/glimmer/swt/latest_message_box_proxy.rb +3 -1
- data/lib/glimmer/swt/latest_shell_proxy.rb +6 -2
- data/lib/glimmer/swt/layout_proxy.rb +32 -9
- data/lib/glimmer/swt/message_box_proxy.rb +20 -10
- data/lib/glimmer/swt/row_layout_proxy.rb +13 -6
- data/lib/glimmer/swt/shell_proxy.rb +30 -8
- data/lib/glimmer/swt/table_proxy.rb +19 -3
- data/lib/glimmer/swt/widget_proxy.rb +50 -19
- data/lib/glimmer/ui/custom_shell.rb +23 -6
- data/lib/glimmer/util/proc_tracker.rb +16 -5
- metadata +11 -9
@@ -35,8 +35,8 @@ class TicTacToe
|
|
35
35
|
(1..3).each { |column|
|
36
36
|
button {
|
37
37
|
layout_data :fill, :fill, true, true
|
38
|
-
text
|
39
|
-
enabled
|
38
|
+
text <= [@tic_tac_toe_board[row, column], :sign]
|
39
|
+
enabled <= [@tic_tac_toe_board[row, column], :empty]
|
40
40
|
font style: :bold, height: 20
|
41
41
|
on_widget_selected {
|
42
42
|
@tic_tac_toe_board.mark(row, column)
|
@@ -52,22 +52,22 @@ class HelloCheckbox
|
|
52
52
|
composite {
|
53
53
|
checkbox {
|
54
54
|
text 'Skiing'
|
55
|
-
selection
|
55
|
+
selection <=> [person, :skiing]
|
56
56
|
}
|
57
57
|
|
58
58
|
checkbox {
|
59
59
|
text 'Snowboarding'
|
60
|
-
selection
|
60
|
+
selection <=> [person, :snowboarding]
|
61
61
|
}
|
62
62
|
|
63
63
|
checkbox {
|
64
64
|
text 'Snowmobiling'
|
65
|
-
selection
|
65
|
+
selection <=> [person, :snowmobiling]
|
66
66
|
}
|
67
67
|
|
68
68
|
checkbox {
|
69
69
|
text 'Snowshoeing'
|
70
|
-
selection
|
70
|
+
selection <=> [person, :snowshoeing]
|
71
71
|
}
|
72
72
|
}
|
73
73
|
|
@@ -46,7 +46,7 @@ class HelloComputed
|
|
46
46
|
|
47
47
|
label {text 'First &Name: '}
|
48
48
|
text {
|
49
|
-
text
|
49
|
+
text <=> [@contact, :first_name]
|
50
50
|
layout_data {
|
51
51
|
horizontal_alignment :fill
|
52
52
|
grab_excess_horizontal_space true
|
@@ -55,7 +55,7 @@ class HelloComputed
|
|
55
55
|
|
56
56
|
label {text '&Last Name: '}
|
57
57
|
text {
|
58
|
-
text
|
58
|
+
text <=> [@contact, :last_name]
|
59
59
|
layout_data {
|
60
60
|
horizontal_alignment :fill
|
61
61
|
grab_excess_horizontal_space true
|
@@ -64,7 +64,7 @@ class HelloComputed
|
|
64
64
|
|
65
65
|
label {text '&Year of Birth: '}
|
66
66
|
text {
|
67
|
-
text
|
67
|
+
text <=> [@contact, :year_of_birth]
|
68
68
|
layout_data {
|
69
69
|
horizontal_alignment :fill
|
70
70
|
grab_excess_horizontal_space true
|
@@ -73,7 +73,7 @@ class HelloComputed
|
|
73
73
|
|
74
74
|
label {text 'Name: '}
|
75
75
|
label {
|
76
|
-
text
|
76
|
+
text <= [@contact, :name, computed_by: [:first_name, :last_name]]
|
77
77
|
layout_data {
|
78
78
|
horizontal_alignment :fill
|
79
79
|
grab_excess_horizontal_space true
|
@@ -82,7 +82,7 @@ class HelloComputed
|
|
82
82
|
|
83
83
|
label {text 'Age: '}
|
84
84
|
label {
|
85
|
-
text
|
85
|
+
text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
|
86
86
|
layout_data {
|
87
87
|
horizontal_alignment :fill
|
88
88
|
grab_excess_horizontal_space true
|
@@ -137,7 +137,7 @@ class HelloCustomShell
|
|
137
137
|
width 360
|
138
138
|
}
|
139
139
|
|
140
|
-
items
|
140
|
+
items <=> [@email_system, :emails, column_attributes: [:date, :subject, :from]]
|
141
141
|
|
142
142
|
on_mouse_up { |event|
|
143
143
|
email = event.table_item.get_data
|
@@ -42,19 +42,19 @@ class HelloDateTime
|
|
42
42
|
}
|
43
43
|
|
44
44
|
date { # alias for date_time(:date)
|
45
|
-
date_time
|
45
|
+
date_time <=> [person, :date_of_birth]
|
46
46
|
}
|
47
47
|
|
48
48
|
date_drop_down { # alias for date_time(:date, :drop_down)
|
49
|
-
date_time
|
49
|
+
date_time <=> [person, :date_of_birth]
|
50
50
|
}
|
51
51
|
|
52
52
|
time { # alias for date_time(:time)
|
53
|
-
date_time
|
53
|
+
date_time <=> [person, :date_of_birth]
|
54
54
|
}
|
55
55
|
|
56
56
|
calendar { # alias for date_time(:calendar)
|
57
|
-
date_time
|
57
|
+
date_time <=> [person, :date_of_birth]
|
58
58
|
}
|
59
59
|
}.open
|
60
60
|
end
|
@@ -54,12 +54,12 @@ class HelloGroup
|
|
54
54
|
|
55
55
|
radio {
|
56
56
|
text 'Male'
|
57
|
-
selection
|
57
|
+
selection <=> [person, :male]
|
58
58
|
}
|
59
59
|
|
60
60
|
radio {
|
61
61
|
text 'Female'
|
62
|
-
selection
|
62
|
+
selection <=> [person, :female]
|
63
63
|
}
|
64
64
|
}
|
65
65
|
|
@@ -71,22 +71,22 @@ class HelloGroup
|
|
71
71
|
|
72
72
|
radio {
|
73
73
|
text 'Child'
|
74
|
-
selection
|
74
|
+
selection <=> [person, :child]
|
75
75
|
}
|
76
76
|
|
77
77
|
radio {
|
78
78
|
text 'Teen'
|
79
|
-
selection
|
79
|
+
selection <=> [person, :teen]
|
80
80
|
}
|
81
81
|
|
82
82
|
radio {
|
83
83
|
text 'Adult'
|
84
|
-
selection
|
84
|
+
selection <=> [person, :adult]
|
85
85
|
}
|
86
86
|
|
87
87
|
radio {
|
88
88
|
text 'Senior'
|
89
|
-
selection
|
89
|
+
selection <=> [person, :senior]
|
90
90
|
}
|
91
91
|
}
|
92
92
|
|
@@ -56,12 +56,12 @@ class HelloRadio
|
|
56
56
|
|
57
57
|
radio {
|
58
58
|
text 'Male'
|
59
|
-
selection
|
59
|
+
selection <=> [person, :male]
|
60
60
|
}
|
61
61
|
|
62
62
|
radio {
|
63
63
|
text 'Female'
|
64
|
-
selection
|
64
|
+
selection <=> [person, :female]
|
65
65
|
}
|
66
66
|
}
|
67
67
|
|
@@ -75,22 +75,22 @@ class HelloRadio
|
|
75
75
|
|
76
76
|
radio {
|
77
77
|
text 'Child'
|
78
|
-
selection
|
78
|
+
selection <=> [person, :child]
|
79
79
|
}
|
80
80
|
|
81
81
|
radio {
|
82
82
|
text 'Teen'
|
83
|
-
selection
|
83
|
+
selection <=> [person, :teen]
|
84
84
|
}
|
85
85
|
|
86
86
|
radio {
|
87
87
|
text 'Adult'
|
88
|
-
selection
|
88
|
+
selection <=> [person, :adult]
|
89
89
|
}
|
90
90
|
|
91
91
|
radio {
|
92
92
|
text 'Senior'
|
93
|
-
selection
|
93
|
+
selection <=> [person, :senior]
|
94
94
|
}
|
95
95
|
}
|
96
96
|
|
@@ -237,10 +237,10 @@ class HelloTable
|
|
237
237
|
}
|
238
238
|
|
239
239
|
# Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
|
240
|
-
items
|
240
|
+
items <=> [BaseballGame, :schedule, column_attributes: [:game_date, :game_time, :ballpark, :home_team, :away_team, :promotion]]
|
241
241
|
|
242
242
|
# Data-bind table selection
|
243
|
-
selection
|
243
|
+
selection <=> [BaseballGame, :selected_game]
|
244
244
|
|
245
245
|
# Default initial sort property
|
246
246
|
sort_property :date
|
@@ -11,11 +11,12 @@ module Glimmer
|
|
11
11
|
include DataBinding::Observable
|
12
12
|
include DataBinding::Observer
|
13
13
|
|
14
|
-
def initialize(parent, model_binding, column_properties)
|
14
|
+
def initialize(parent, model_binding, column_properties = nil)
|
15
15
|
@last_populated_model_collection = nil
|
16
16
|
@table = parent
|
17
17
|
@model_binding = model_binding
|
18
|
-
@column_properties = column_properties
|
18
|
+
@column_properties = model_binding.binding_options[:column_attributes] || model_binding.binding_options[:column_properties] || column_properties # TODO
|
19
|
+
@table.editable = false if model_binding.binding_options[:read_only]
|
19
20
|
@table.data = @model_binding
|
20
21
|
##@table.on_widget_disposed do |dispose_event| # doesn't seem needed within Opal
|
21
22
|
## unregister_all_observables
|
@@ -1,36 +1,35 @@
|
|
1
|
+
# Copyright (c) 2020-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
|
+
|
1
22
|
require 'glimmer/dsl/static_expression'
|
23
|
+
require 'glimmer/dsl/bind_expression'
|
2
24
|
require 'glimmer/data_binding/model_binding'
|
3
25
|
|
4
26
|
module Glimmer
|
5
27
|
module DSL
|
6
28
|
module Opal
|
7
29
|
# Responsible for setting up the return value of the bind keyword (command symbol)
|
8
|
-
# as a ModelBinding. It is then used by
|
9
|
-
# DataBindingCommandHandler for text and selection properties on Text and Spinner
|
10
|
-
# or TableItemsDataBindingCommandHandler for items in a Table
|
30
|
+
# as a ModelBinding. It is then used by other data-binding expressions
|
11
31
|
class BindExpression < StaticExpression
|
12
|
-
|
13
|
-
(
|
14
|
-
keyword == 'bind' and
|
15
|
-
(
|
16
|
-
(
|
17
|
-
(args.size == 2) and
|
18
|
-
textual?(args[1])
|
19
|
-
) ||
|
20
|
-
(
|
21
|
-
(args.size == 3) and
|
22
|
-
textual?(args[1]) and
|
23
|
-
(args[2].is_a?(Hash))
|
24
|
-
)
|
25
|
-
)
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
def interpret(parent, keyword, *args, &block)
|
30
|
-
binding_options = args[2] || {}
|
31
|
-
binding_options[:on_read] = binding_options.delete(:on_read) || binding_options.delete('on_read') || block
|
32
|
-
DataBinding::ModelBinding.new(args[0], args[1].to_s, binding_options)
|
33
|
-
end
|
32
|
+
include Glimmer::DSL::BindExpression
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
@@ -51,7 +51,7 @@ module Glimmer
|
|
51
51
|
custom_widget_class = UI::CustomWidget.for(keyword)
|
52
52
|
# TODO clean code by extracting methods into CustomShell
|
53
53
|
if !Glimmer::UI::CustomShell.requested? && custom_widget_class&.ancestors&.to_a.include?(Glimmer::UI::CustomShell)
|
54
|
-
if Glimmer::SWT::DisplayProxy.instance.shells.empty?
|
54
|
+
if Glimmer::SWT::DisplayProxy.instance.shells.empty? || Glimmer::SWT::DisplayProxy.open_custom_shells_in_current_window?
|
55
55
|
custom_widget_class.new(parent, *args, {}, &block)
|
56
56
|
else
|
57
57
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
@@ -80,12 +80,12 @@ module Glimmer
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
83
|
+
# TODO delete if no longer needed
|
84
|
+
# def add_content(parent, &content)
|
85
|
+
# content.call(parent) if parent.is_a?(Glimmer::SWT::ShellProxy) || parent.is_a?(Glimmer::UI::CustomShell)
|
86
|
+
# end
|
87
87
|
|
88
|
-
def add_content(parent, &block)
|
88
|
+
def add_content(parent, keyword, *args, &block)
|
89
89
|
return unless parent.is_a?(Glimmer::UI::CustomWidget)
|
90
90
|
# TODO consider avoiding source_location
|
91
91
|
if block.source_location == parent.content&.__getobj__.source_location
|
data/lib/glimmer/dsl/opal/dsl.rb
CHANGED
@@ -28,6 +28,8 @@ require 'glimmer/dsl/opal/checkbox_group_selection_data_binding_expression'
|
|
28
28
|
require 'glimmer/dsl/opal/block_property_expression'
|
29
29
|
require 'glimmer/dsl/opal/menu_expression'
|
30
30
|
require 'glimmer/dsl/opal/dialog_expression'
|
31
|
+
require 'glimmer/dsl/opal/shape_expression'
|
32
|
+
require 'glimmer/dsl/opal/shine_data_binding_expression'
|
31
33
|
|
32
34
|
module Glimmer
|
33
35
|
module DSL
|
@@ -47,6 +49,8 @@ module Glimmer
|
|
47
49
|
layout
|
48
50
|
block_property
|
49
51
|
property
|
52
|
+
shine_data_binding
|
53
|
+
shape
|
50
54
|
widget
|
51
55
|
]
|
52
56
|
)
|
@@ -6,8 +6,9 @@ module Glimmer
|
|
6
6
|
class PropertyExpression < StaticExpression
|
7
7
|
include TopLevelExpression
|
8
8
|
|
9
|
-
def can_interpret?(parent, keyword, *args, &block)
|
9
|
+
def can_interpret?(parent, keyword, *args, &block)
|
10
10
|
parent and
|
11
|
+
(!args.empty?) and
|
11
12
|
parent.respond_to?(:set_attribute) and
|
12
13
|
parent.respond_to?(keyword, *args) and
|
13
14
|
keyword and
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'glimmer/dsl/expression'
|
2
|
+
require 'glimmer/dsl/parent_expression'
|
3
|
+
|
4
|
+
module Glimmer
|
5
|
+
module DSL
|
6
|
+
module Opal
|
7
|
+
class ShapeExpression < Expression
|
8
|
+
include ParentExpression
|
9
|
+
|
10
|
+
INCLUDED_KEYWORDS = %w[rectangle polygon]
|
11
|
+
|
12
|
+
def can_interpret?(parent, keyword, *args, &block)
|
13
|
+
INCLUDED_KEYWORDS.include?(keyword)
|
14
|
+
end
|
15
|
+
|
16
|
+
def interpret(parent, keyword, *args, &block)
|
17
|
+
# TODO
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_content(parent, keyword, *args, &block)
|
21
|
+
# TODO
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|