glimmer-dsl-opal 0.0.9 → 0.5.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 +50 -0
- data/README.md +999 -177
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal.rb +49 -10
- data/lib/glimmer-dsl-opal/ext/date.rb +13 -0
- data/lib/glimmer-dsl-opal/ext/exception.rb +5 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager.rb +1 -1
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_manager_presenter.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_repository.rb +24 -99
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/login.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/board.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/cell.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_browser.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +85 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +68 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +63 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed.rb +19 -19
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed/contact.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +155 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +86 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +104 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_multi_selection.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_single_selection.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +108 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +84 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +50 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +29 -0
- data/lib/glimmer-dsl-opal/vendor/jquery.js +2 -0
- data/lib/glimmer-dsl-swt.rb +37 -0
- data/lib/glimmer/data_binding/element_binding.rb +1 -0
- data/lib/glimmer/data_binding/ext/observable_model.rb +5 -5
- data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +3 -3
- data/lib/glimmer/dsl/opal/async_exec_expression.rb +23 -7
- data/lib/glimmer/dsl/opal/checkbox_group_selection_data_binding_expression.rb +61 -0
- data/lib/glimmer/dsl/opal/color_expression.rb +38 -0
- data/lib/glimmer/dsl/opal/column_properties_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +94 -0
- data/lib/glimmer/dsl/opal/display_expression.rb +40 -0
- data/lib/glimmer/dsl/opal/dsl.rb +18 -16
- data/lib/glimmer/dsl/opal/exec_expression.rb +55 -0
- data/lib/glimmer/dsl/opal/font_expression.rb +47 -0
- data/lib/glimmer/dsl/opal/layout_data_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/layout_expression.rb +22 -0
- data/lib/glimmer/dsl/opal/list_selection_data_binding_expression.rb +2 -3
- data/lib/glimmer/dsl/opal/message_box_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/property_expression.rb +6 -2
- data/lib/glimmer/dsl/opal/radio_group_selection_data_binding_expression.rb +61 -0
- data/lib/glimmer/dsl/opal/rgb_expression.rb +32 -0
- data/lib/glimmer/dsl/opal/rgba_expression.rb +32 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +20 -3
- data/lib/glimmer/dsl/opal/swt_expression.rb +46 -0
- data/lib/glimmer/dsl/opal/sync_exec_expression.rb +33 -0
- data/lib/glimmer/dsl/opal/table_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/widget_expression.rb +24 -0
- data/lib/glimmer/dsl/opal/widget_listener_expression.rb +16 -3
- data/lib/glimmer/swt.rb +499 -0
- data/lib/glimmer/swt/browser_proxy.rb +27 -0
- data/lib/glimmer/swt/button_proxy.rb +54 -0
- data/lib/glimmer/swt/checkbox_proxy.rb +80 -0
- data/lib/glimmer/swt/color_proxy.rb +119 -0
- data/lib/glimmer/{opal/select_proxy.rb → swt/combo_proxy.rb} +23 -18
- data/lib/glimmer/swt/composite_proxy.rb +31 -0
- data/lib/glimmer/swt/custom/checkbox_group.rb +142 -0
- data/lib/glimmer/swt/custom/radio_group.rb +143 -0
- data/lib/glimmer/swt/display_proxy.rb +79 -0
- data/lib/glimmer/{opal → swt}/event_listener_proxy.rb +1 -1
- data/lib/glimmer/swt/fill_layout_proxy.rb +84 -0
- data/lib/glimmer/swt/font_proxy.rb +79 -0
- data/lib/glimmer/swt/grid_layout_proxy.rb +82 -0
- data/lib/glimmer/swt/group_proxy.rb +38 -0
- data/lib/glimmer/swt/label_proxy.rb +54 -0
- data/lib/glimmer/swt/layout_data_proxy.rb +105 -0
- data/lib/glimmer/swt/layout_proxy.rb +63 -0
- data/lib/glimmer/{opal → swt}/list_proxy.rb +30 -22
- data/lib/glimmer/swt/make_shift_shell_proxy.rb +38 -0
- data/lib/glimmer/swt/message_box_proxy.rb +143 -0
- data/lib/glimmer/{opal → swt}/point.rb +1 -1
- data/lib/glimmer/{opal → swt}/property_owner.rb +1 -1
- data/lib/glimmer/swt/radio_proxy.rb +81 -0
- data/lib/glimmer/swt/row_layout_proxy.rb +128 -0
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +20 -0
- data/lib/glimmer/swt/shell_proxy.rb +260 -0
- data/lib/glimmer/swt/style_constantizable.rb +154 -0
- data/lib/glimmer/swt/styled_text_proxy.rb +44 -0
- data/lib/glimmer/swt/swt_proxy.rb +53 -0
- data/lib/glimmer/{opal/tab_folder.rb → swt/tab_folder_proxy.rb} +20 -21
- data/lib/glimmer/swt/tab_item_proxy.rb +84 -0
- data/lib/glimmer/{opal/table_column.rb → swt/table_column_proxy.rb} +13 -7
- data/lib/glimmer/{opal/table_item.rb → swt/table_item_proxy.rb} +59 -48
- data/lib/glimmer/{opal → swt}/table_proxy.rb +66 -56
- data/lib/glimmer/swt/text_proxy.rb +46 -0
- data/lib/glimmer/swt/widget_proxy.rb +511 -0
- data/lib/glimmer/ui/custom_shell.rb +92 -0
- data/lib/glimmer/ui/custom_widget.rb +292 -0
- data/lib/glimmer/util/proc_tracker.rb +39 -0
- data/lib/net/http.rb +17 -0
- data/lib/uri.rb +64 -0
- metadata +142 -67
- data/lib/glimmer/dsl/opal/browser_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/button_expression.rb +0 -18
- data/lib/glimmer/dsl/opal/combo_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/composite_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/grid_layout_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/label_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/list_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/tab_folder_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/tab_item_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/text_expression.rb +0 -22
- data/lib/glimmer/opal/display_proxy.rb +0 -23
- data/lib/glimmer/opal/div_proxy.rb +0 -29
- data/lib/glimmer/opal/document_proxy.rb +0 -187
- data/lib/glimmer/opal/element_proxy.rb +0 -304
- data/lib/glimmer/opal/grid_layout_proxy.rb +0 -54
- data/lib/glimmer/opal/iframe_proxy.rb +0 -23
- data/lib/glimmer/opal/input_proxy.rb +0 -45
- data/lib/glimmer/opal/label_proxy.rb +0 -25
- data/lib/glimmer/opal/layout_data_proxy.rb +0 -52
- data/lib/glimmer/opal/modal.rb +0 -94
- data/lib/glimmer/opal/tab_item.rb +0 -98
- data/lib/samples/elaborate/launch +0 -6
- data/lib/samples/hello/hello_combo.rb +0 -34
- data/lib/samples/hello/hello_tab.rb +0 -24
- data/lib/samples/hello/hello_world.rb +0 -8
- data/lib/samples/hello/launch +0 -10
- data/lib/samples/launch +0 -4
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'glimmer/dsl/static_expression'
|
2
|
-
require 'glimmer/dsl/parent_expression'
|
3
|
-
require 'glimmer/opal/tab_item'
|
4
|
-
|
5
|
-
module Glimmer
|
6
|
-
module DSL
|
7
|
-
module Opal
|
8
|
-
class TabItemExpression < StaticExpression
|
9
|
-
include ParentExpression
|
10
|
-
|
11
|
-
def interpret(parent, keyword, *args, &block)
|
12
|
-
Glimmer::Opal::TabItem.new(parent, args)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'glimmer/dsl/expression'
|
2
|
-
require 'glimmer/dsl/parent_expression'
|
3
|
-
require 'glimmer/opal/input_proxy'
|
4
|
-
|
5
|
-
module Glimmer
|
6
|
-
module DSL
|
7
|
-
module Opal
|
8
|
-
class TextExpression < Expression
|
9
|
-
include ParentExpression
|
10
|
-
|
11
|
-
def can_interpret?(parent, keyword, *args, &block)
|
12
|
-
keyword == 'text' and parent and block_given?
|
13
|
-
end
|
14
|
-
|
15
|
-
def interpret(parent, keyword, *args, &block)
|
16
|
-
args << {type: 'text'}
|
17
|
-
Glimmer::Opal::InputProxy.new(parent, args)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Glimmer
|
2
|
-
module Opal
|
3
|
-
class DisplayProxy
|
4
|
-
class << self
|
5
|
-
def instance
|
6
|
-
@instance ||= new
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def async_exec(&block)
|
11
|
-
executer = lambda do
|
12
|
-
if $document.at_css('.modal')
|
13
|
-
sleep(0.05)
|
14
|
-
Async::Task.new(&executer)
|
15
|
-
else
|
16
|
-
block.call
|
17
|
-
end
|
18
|
-
end
|
19
|
-
Async::Task.new(&executer)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'glimmer/opal/element_proxy'
|
2
|
-
|
3
|
-
module Glimmer
|
4
|
-
module Opal
|
5
|
-
class DivProxy < ElementProxy
|
6
|
-
attr_reader :layout
|
7
|
-
|
8
|
-
def initialize(parent, args)
|
9
|
-
super(parent, args)
|
10
|
-
@layout = GridLayoutProxy.new(self, [])
|
11
|
-
end
|
12
|
-
|
13
|
-
def redraw
|
14
|
-
super()
|
15
|
-
@children.each do |child|
|
16
|
-
add_child(child) # TODO think of impact of this on performance, and of other alternatives
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def dom
|
21
|
-
div_id = id
|
22
|
-
div_style = css
|
23
|
-
@dom ||= DOM {
|
24
|
-
div(id: div_id, class: 'grid-layout', style: div_style)
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,187 +0,0 @@
|
|
1
|
-
require 'glimmer/opal/element_proxy'
|
2
|
-
require 'glimmer/opal/point'
|
3
|
-
|
4
|
-
module Glimmer
|
5
|
-
module Opal
|
6
|
-
class DocumentProxy < ElementProxy
|
7
|
-
# TODO consider renaming to ShellProxy to match SWT API
|
8
|
-
attr_reader :minimum_size
|
9
|
-
|
10
|
-
def initialize(args)
|
11
|
-
@args = args
|
12
|
-
@children = []
|
13
|
-
$document.ready do
|
14
|
-
$document.head.replace(head_dom)
|
15
|
-
$document.body.replace(dom)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def text
|
20
|
-
$document.title
|
21
|
-
end
|
22
|
-
|
23
|
-
def text=(value)
|
24
|
-
$document.ready do
|
25
|
-
$document.title = value
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def minimum_size=(width_or_minimum_size, height = nil)
|
30
|
-
@minimum_size = height.nil? ? width_or_minimum_size : Point.new(width_or_minimum_size, height)
|
31
|
-
redraw
|
32
|
-
end
|
33
|
-
|
34
|
-
def head_dom
|
35
|
-
# TODO make grid-layout support grab excess space false
|
36
|
-
@head_dom ||= DOM {
|
37
|
-
head {
|
38
|
-
<<~CSS
|
39
|
-
<style>
|
40
|
-
html {
|
41
|
-
width: 100%;
|
42
|
-
height: 100%;
|
43
|
-
}
|
44
|
-
body {
|
45
|
-
width: 100%;
|
46
|
-
height: 100%;
|
47
|
-
margin: 0;
|
48
|
-
}
|
49
|
-
body > iframe {
|
50
|
-
width: 100%;
|
51
|
-
height: 100%;
|
52
|
-
}
|
53
|
-
ul {
|
54
|
-
list-style: none;
|
55
|
-
padding: 0;
|
56
|
-
}
|
57
|
-
li {
|
58
|
-
cursor: default;
|
59
|
-
padding-left: 10px;
|
60
|
-
padding-right: 10px;
|
61
|
-
}
|
62
|
-
li.empty-list-item {
|
63
|
-
color: transparent;
|
64
|
-
}
|
65
|
-
.tabs {
|
66
|
-
overflow: hidden;
|
67
|
-
border: 1px solid #ccc;
|
68
|
-
background-color: #f1f1f1;
|
69
|
-
}
|
70
|
-
|
71
|
-
/* Style the buttons inside the tab */
|
72
|
-
.tabs .tab {
|
73
|
-
background-color: inherit;
|
74
|
-
float: left;
|
75
|
-
border: none;
|
76
|
-
outline: none;
|
77
|
-
cursor: pointer;
|
78
|
-
padding: 14px 16px;
|
79
|
-
transition: 0.3s;
|
80
|
-
font-size: 17px;
|
81
|
-
}
|
82
|
-
|
83
|
-
/* Change background color of buttons on hover */
|
84
|
-
.tabs .tab:hover {
|
85
|
-
background-color: #ddd;
|
86
|
-
}
|
87
|
-
|
88
|
-
/* Create an active/current tablink class */
|
89
|
-
.tabs .tab.active {
|
90
|
-
background-color: #ccc;
|
91
|
-
}
|
92
|
-
|
93
|
-
/* Style the tab content */
|
94
|
-
.tab-item {
|
95
|
-
padding: 6px 12px;
|
96
|
-
border: 1px solid #ccc;
|
97
|
-
border-top: none;
|
98
|
-
}
|
99
|
-
|
100
|
-
.hide {
|
101
|
-
display: none !important;
|
102
|
-
}
|
103
|
-
|
104
|
-
/* The Modal (background) */
|
105
|
-
.modal {
|
106
|
-
position: fixed; /* Stay in place */
|
107
|
-
z-index: 1; /* Sit on top */
|
108
|
-
padding-top: 100px; /* Location of the box */
|
109
|
-
left: 0;
|
110
|
-
top: 0;
|
111
|
-
width: 100%; /* Full width */
|
112
|
-
height: 100%; /* Full height */
|
113
|
-
overflow: auto; /* Enable scroll if needed */
|
114
|
-
background-color: rgb(0,0,0); /* Fallback color */
|
115
|
-
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
116
|
-
text-align: center;
|
117
|
-
}
|
118
|
-
|
119
|
-
/* Modal Content */
|
120
|
-
.modal-content {
|
121
|
-
background-color: #fefefe;
|
122
|
-
margin: auto;
|
123
|
-
border: 1px solid #888;
|
124
|
-
display: inline-block;
|
125
|
-
min-width: 200px;
|
126
|
-
}
|
127
|
-
|
128
|
-
.modal-content .text {
|
129
|
-
background: rgb(80, 116, 211);
|
130
|
-
color: white;
|
131
|
-
padding: 5px;
|
132
|
-
}
|
133
|
-
|
134
|
-
.modal-content .message {
|
135
|
-
padding: 20px;
|
136
|
-
}
|
137
|
-
|
138
|
-
/* The Close Button */
|
139
|
-
.close {
|
140
|
-
color: #aaaaaa;
|
141
|
-
float: right;
|
142
|
-
font-weight: bold;
|
143
|
-
margin: 5px;
|
144
|
-
}
|
145
|
-
|
146
|
-
.close:hover,
|
147
|
-
.close:focus {
|
148
|
-
color: #000;
|
149
|
-
text-decoration: none;
|
150
|
-
cursor: pointer;
|
151
|
-
}
|
152
|
-
|
153
|
-
.selected {
|
154
|
-
background: rgb(80, 116, 211);
|
155
|
-
color: white;
|
156
|
-
}
|
157
|
-
|
158
|
-
table {
|
159
|
-
border-spacing: 0;
|
160
|
-
}
|
161
|
-
|
162
|
-
table tr th,td {
|
163
|
-
cursor: default;
|
164
|
-
}
|
165
|
-
|
166
|
-
</style>
|
167
|
-
CSS
|
168
|
-
}
|
169
|
-
}
|
170
|
-
end
|
171
|
-
|
172
|
-
def dom
|
173
|
-
i = 0
|
174
|
-
body_style = ''
|
175
|
-
body_style += "min-width: #{@minimum_size.x}px; min-height: #{@minimum_size.y}px;" if @minimum_size
|
176
|
-
@dom ||= DOM {
|
177
|
-
body(style: body_style) {
|
178
|
-
}
|
179
|
-
}
|
180
|
-
end
|
181
|
-
|
182
|
-
def open
|
183
|
-
# No Op (just a placeholder since it is not needed on the web)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
@@ -1,304 +0,0 @@
|
|
1
|
-
require 'glimmer/opal/property_owner'
|
2
|
-
|
3
|
-
module Glimmer
|
4
|
-
module Opal
|
5
|
-
class ElementProxy
|
6
|
-
include Glimmer
|
7
|
-
include PropertyOwner
|
8
|
-
attr_reader :parent, :args, :css_classes, :css, :children, :enabled
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def next_id_number_for(name)
|
12
|
-
@max_id_numbers[name] = max_id_number_for(name) + 1
|
13
|
-
end
|
14
|
-
|
15
|
-
def max_id_number_for(name)
|
16
|
-
@max_id_numbers[name] = max_id_numbers[name] || 0
|
17
|
-
end
|
18
|
-
|
19
|
-
def max_id_numbers
|
20
|
-
@max_id_numbers ||= {}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def initialize(parent, args)
|
25
|
-
@parent = parent
|
26
|
-
@args = args
|
27
|
-
@children = Set.new
|
28
|
-
@css_classes = Set.new
|
29
|
-
@css = ''
|
30
|
-
@enabled = true
|
31
|
-
@parent.add_child(self)
|
32
|
-
end
|
33
|
-
|
34
|
-
def add_child(child)
|
35
|
-
# return if @children.include?(child) # TODO consider adding an option to enable this if needed to prevent dom repetition
|
36
|
-
@children << child
|
37
|
-
dom << child.dom
|
38
|
-
end
|
39
|
-
|
40
|
-
def enabled=(value)
|
41
|
-
@enabled = value
|
42
|
-
redraw
|
43
|
-
end
|
44
|
-
|
45
|
-
def redraw
|
46
|
-
if @dom
|
47
|
-
old_dom = @dom
|
48
|
-
@dom = nil
|
49
|
-
old_dom.replace dom
|
50
|
-
else
|
51
|
-
dom
|
52
|
-
end
|
53
|
-
@children.each do |child|
|
54
|
-
child.redraw
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Subclasses must override with their own mappings
|
59
|
-
def observation_request_to_event_mapping
|
60
|
-
{}
|
61
|
-
end
|
62
|
-
|
63
|
-
def name
|
64
|
-
self.class.name.split('::').last.underscore.sub(/_proxy$/, '')
|
65
|
-
end
|
66
|
-
|
67
|
-
def id
|
68
|
-
@id ||= "#{name}-#{ElementProxy.next_id_number_for(name)}"
|
69
|
-
end
|
70
|
-
|
71
|
-
# Sets id explicitly. Useful in cases of wanting to maintain a stable id
|
72
|
-
def id=(value)
|
73
|
-
@id = value
|
74
|
-
end
|
75
|
-
|
76
|
-
# Subclasses can override with their own selector
|
77
|
-
def selector
|
78
|
-
"#{name}##{id}"
|
79
|
-
end
|
80
|
-
|
81
|
-
def add_css_class(css_class)
|
82
|
-
@css_classes << css_class
|
83
|
-
redraw
|
84
|
-
end
|
85
|
-
|
86
|
-
def add_css_classes(css_classes)
|
87
|
-
@css_classes += css_classes
|
88
|
-
redraw
|
89
|
-
end
|
90
|
-
|
91
|
-
def remove_css_class(css_class)
|
92
|
-
@css_classes.delete(css_class)
|
93
|
-
redraw
|
94
|
-
end
|
95
|
-
|
96
|
-
def remove_css_classes(css_classes)
|
97
|
-
@css_classes -= css_classes
|
98
|
-
redraw
|
99
|
-
end
|
100
|
-
|
101
|
-
def clear_css_classes(css_class)
|
102
|
-
@css_classes.clear
|
103
|
-
redraw
|
104
|
-
end
|
105
|
-
|
106
|
-
def css=(css)
|
107
|
-
@css = css
|
108
|
-
redraw
|
109
|
-
end
|
110
|
-
|
111
|
-
def has_style?(symbol)
|
112
|
-
@args.include?(symbol) # not a very solid implementation. Bring SWT constants eventually
|
113
|
-
end
|
114
|
-
|
115
|
-
def handle_observation_request(keyword, &event_listener)
|
116
|
-
return unless observation_request_to_event_mapping.keys.include?(keyword)
|
117
|
-
event = nil
|
118
|
-
delegate = nil
|
119
|
-
[observation_request_to_event_mapping[keyword]].flatten.each do |mapping|
|
120
|
-
event = mapping[:event]
|
121
|
-
event_handler = mapping[:event_handler]
|
122
|
-
potential_event_listener = event_handler&.call(event_listener)
|
123
|
-
event_listener = event_handler&.call(event_listener) || event_listener
|
124
|
-
delegate = $document.on(event, selector, &event_listener)
|
125
|
-
end
|
126
|
-
EventListenerProxy.new(element_proxy: self, event: event, selector: selector, delegate: delegate)
|
127
|
-
end
|
128
|
-
|
129
|
-
def add_observer(observer, property_name)
|
130
|
-
property_listener_installers = self.class.ancestors.map {|ancestor| widget_property_listener_installers[ancestor]}.compact
|
131
|
-
widget_listener_installers = property_listener_installers.map{|installer| installer[property_name.to_s.to_sym]}.compact if !property_listener_installers.empty?
|
132
|
-
widget_listener_installers.to_a.each do |widget_listener_installer|
|
133
|
-
widget_listener_installer.call(observer)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def set_attribute(attribute_name, *args)
|
138
|
-
apply_property_type_converters(attribute_name, args)
|
139
|
-
super(attribute_name, *args)
|
140
|
-
end
|
141
|
-
|
142
|
-
def apply_property_type_converters(attribute_name, args)
|
143
|
-
if args.count == 1
|
144
|
-
value = args.first
|
145
|
-
converter = property_type_converters[attribute_name.to_sym]
|
146
|
-
args[0] = converter.call(value) if converter
|
147
|
-
end
|
148
|
-
# if args.count == 1 && args.first.is_a?(ColorProxy)
|
149
|
-
# g_color = args.first
|
150
|
-
# args[0] = g_color.swt_color
|
151
|
-
# end
|
152
|
-
end
|
153
|
-
|
154
|
-
def property_type_converters
|
155
|
-
@property_type_converters ||= {
|
156
|
-
# :background => color_converter,
|
157
|
-
# :background_image => lambda do |value|
|
158
|
-
# if value.is_a?(String)
|
159
|
-
# if value.start_with?('uri:classloader')
|
160
|
-
# value = value.sub(/^uri\:classloader\:\//, '')
|
161
|
-
# object = java.lang.Object.new
|
162
|
-
# value = object.java_class.resource_as_stream(value)
|
163
|
-
# value = java.io.BufferedInputStream.new(value)
|
164
|
-
# end
|
165
|
-
# image_data = ImageData.new(value)
|
166
|
-
# on_event_Resize do |resize_event|
|
167
|
-
# new_image_data = image_data.scaledTo(@swt_widget.getSize.x, @swt_widget.getSize.y)
|
168
|
-
# @swt_widget.getBackgroundImage&.dispose
|
169
|
-
# @swt_widget.setBackgroundImage(Image.new(@swt_widget.getDisplay, new_image_data))
|
170
|
-
# end
|
171
|
-
# Image.new(@swt_widget.getDisplay, image_data)
|
172
|
-
# else
|
173
|
-
# value
|
174
|
-
# end
|
175
|
-
# end,
|
176
|
-
# :foreground => color_converter,
|
177
|
-
# :font => lambda do |value|
|
178
|
-
# if value.is_a?(Hash)
|
179
|
-
# font_properties = value
|
180
|
-
# FontProxy.new(self, font_properties).swt_font
|
181
|
-
# else
|
182
|
-
# value
|
183
|
-
# end
|
184
|
-
# end,
|
185
|
-
# :items => lambda do |value|
|
186
|
-
# value.to_java :string
|
187
|
-
# end,
|
188
|
-
:text => lambda do |value|
|
189
|
-
# if swt_widget.is_a?(Browser)
|
190
|
-
# value.to_s
|
191
|
-
# else
|
192
|
-
value.to_s
|
193
|
-
# end
|
194
|
-
end,
|
195
|
-
# :visible => lambda do |value|
|
196
|
-
# !!value
|
197
|
-
# end,
|
198
|
-
}
|
199
|
-
end
|
200
|
-
|
201
|
-
def widget_property_listener_installers
|
202
|
-
@swt_widget_property_listener_installers ||= {
|
203
|
-
# ElementProxy => {
|
204
|
-
# :focus => lambda do |observer|
|
205
|
-
# on_focus_gained { |focus_event|
|
206
|
-
# observer.call(true)
|
207
|
-
# }
|
208
|
-
# on_focus_lost { |focus_event|
|
209
|
-
# observer.call(false)
|
210
|
-
# }
|
211
|
-
# end,
|
212
|
-
# },
|
213
|
-
InputProxy => {
|
214
|
-
:text => lambda do |observer|
|
215
|
-
on_modify_text { |modify_event|
|
216
|
-
observer.call(text)
|
217
|
-
}
|
218
|
-
end,
|
219
|
-
# :caret_position => lambda do |observer|
|
220
|
-
# on_event_keydown { |event|
|
221
|
-
# observer.call(getCaretPosition)
|
222
|
-
# }
|
223
|
-
# on_event_keyup { |event|
|
224
|
-
# observer.call(getCaretPosition)
|
225
|
-
# }
|
226
|
-
# on_event_mousedown { |event|
|
227
|
-
# observer.call(getCaretPosition)
|
228
|
-
# }
|
229
|
-
# on_event_mouseup { |event|
|
230
|
-
# observer.call(getCaretPosition)
|
231
|
-
# }
|
232
|
-
# end,
|
233
|
-
# :selection => lambda do |observer|
|
234
|
-
# on_event_keydown { |event|
|
235
|
-
# observer.call(getSelection)
|
236
|
-
# }
|
237
|
-
# on_event_keyup { |event|
|
238
|
-
# observer.call(getSelection)
|
239
|
-
# }
|
240
|
-
# on_event_mousedown { |event|
|
241
|
-
# observer.call(getSelection)
|
242
|
-
# }
|
243
|
-
# on_event_mouseup { |event|
|
244
|
-
# observer.call(getSelection)
|
245
|
-
# }
|
246
|
-
# end,
|
247
|
-
# :selection_count => lambda do |observer|
|
248
|
-
# on_event_keydown { |event|
|
249
|
-
# observer.call(getSelectionCount)
|
250
|
-
# }
|
251
|
-
# on_event_keyup { |event|
|
252
|
-
# observer.call(getSelectionCount)
|
253
|
-
# }
|
254
|
-
# on_event_mousedown { |event|
|
255
|
-
# observer.call(getSelectionCount)
|
256
|
-
# }
|
257
|
-
# on_event_mouseup { |event|
|
258
|
-
# observer.call(getSelectionCount)
|
259
|
-
# }
|
260
|
-
# end,
|
261
|
-
# :top_index => lambda do |observer|
|
262
|
-
# @last_top_index = getTopIndex
|
263
|
-
# on_paint_control { |event|
|
264
|
-
# if getTopIndex != @last_top_index
|
265
|
-
# @last_top_index = getTopIndex
|
266
|
-
# observer.call(@last_top_index)
|
267
|
-
# end
|
268
|
-
# }
|
269
|
-
# end,
|
270
|
-
},
|
271
|
-
# Java::OrgEclipseSwtCustom::StyledText => {
|
272
|
-
# :text => lambda do |observer|
|
273
|
-
# on_modify_text { |modify_event|
|
274
|
-
# observer.call(getText)
|
275
|
-
# }
|
276
|
-
# end,
|
277
|
-
# },
|
278
|
-
# InputProxy => {
|
279
|
-
# :selection => lambda do |observer|
|
280
|
-
# on_widget_selected { |selection_event|
|
281
|
-
# observer.call(getSelection)
|
282
|
-
# }
|
283
|
-
# end
|
284
|
-
# },
|
285
|
-
# Java::OrgEclipseSwtWidgets::MenuItem => {
|
286
|
-
# :selection => lambda do |observer|
|
287
|
-
# on_widget_selected { |selection_event|
|
288
|
-
# observer.call(getSelection)
|
289
|
-
# }
|
290
|
-
# end
|
291
|
-
# },
|
292
|
-
# Java::OrgEclipseSwtWidgets::Spinner => {
|
293
|
-
# :selection => lambda do |observer|
|
294
|
-
# on_widget_selected { |selection_event|
|
295
|
-
# observer.call(getSelection)
|
296
|
-
# }
|
297
|
-
# end
|
298
|
-
# },
|
299
|
-
}
|
300
|
-
end
|
301
|
-
|
302
|
-
end
|
303
|
-
end
|
304
|
-
end
|