glimmer-dsl-swt 0.3.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,9 +5,10 @@ module Glimmer
5
5
  module CustomShell
6
6
  include SuperModule
7
7
  include Glimmer::UI::CustomWidget
8
-
8
+
9
9
  def initialize(parent, *swt_constants, options, &content)
10
10
  super
11
+ @swt_widget.set_data('custom_shell', self)
11
12
  raise Error, 'Invalid custom shell body root! Must be a shell or another custom shell.' unless body_root.swt_widget.is_a?(org.eclipse.swt.widgets.Shell)
12
13
  end
13
14
 
@@ -5,7 +5,6 @@ require 'glimmer/swt/display_proxy'
5
5
  require 'glimmer/util/proc_tracker'
6
6
  require 'glimmer/data_binding/observer'
7
7
  require 'glimmer/data_binding/observable_model'
8
- require 'glimmer/data_binding/observable_widget'
9
8
 
10
9
  module Glimmer
11
10
  module UI
@@ -15,7 +14,6 @@ module Glimmer
15
14
 
16
15
  super_module_included do |klass|
17
16
  klass.include(Glimmer) unless klass.name.include?('Glimmer::UI::CustomShell')
18
- klass.prepend DataBinding::ObservableWidget
19
17
  Glimmer::UI::CustomWidget.add_custom_widget_namespaces_for(klass) unless klass.name.include?('Glimmer::UI::CustomShell')
20
18
  end
21
19
 
@@ -36,15 +34,15 @@ module Glimmer
36
34
  return constant if constant.ancestors.include?(Glimmer::UI::CustomWidget)
37
35
  constant
38
36
  rescue => e
39
- # Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
37
+ # Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
40
38
  result
41
39
  end
42
40
  end
43
41
  end
44
42
  raise "#{underscored_custom_widget_name} has no custom widget class!"
45
43
  rescue => e
46
- Glimmer::Config.logger&.debug e.message
47
- Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
44
+ Glimmer::Config.logger.debug {e.message}
45
+ Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
48
46
  nil
49
47
  end
50
48
 
@@ -134,16 +132,18 @@ module Glimmer
134
132
  body_block = self.class.instance_variable_get("@body_block")
135
133
  raise Glimmer::Error, 'Invalid custom widget for having no body! Please define body block!' if body_block.nil?
136
134
  @body_root = instance_exec(&body_block)
137
- execute_hooks('after_body')
138
135
  @swt_widget = @body_root.swt_widget
136
+ @swt_widget.set_data('custom_widget', self)
137
+ execute_hooks('after_body')
139
138
  end
140
139
 
141
140
  # Subclasses may override to perform post initialization work on an added child
142
141
  def post_initialize_child(child)
143
- body_root.post_initialize_child(child)
144
- end
142
+ # No Op by default
143
+ end
145
144
 
146
145
  def can_handle_observation_request?(observation_request)
146
+ observation_request = observation_request.to_s
147
147
  result = false
148
148
  if observation_request.start_with?('on_updated_')
149
149
  property = observation_request.sub(/^on_updated_/, '')
@@ -153,6 +153,7 @@ module Glimmer
153
153
  end
154
154
 
155
155
  def handle_observation_request(observation_request, &block)
156
+ observation_request = observation_request.to_s
156
157
  if observation_request.start_with?('on_updated_')
157
158
  property = observation_request.sub(/^on_updated_/, '') # TODO look into eliminating duplication from above
158
159
  add_observer(DataBinding::Observer.proc(&block), property) if can_add_observer?(property)
@@ -162,7 +163,7 @@ module Glimmer
162
163
  end
163
164
 
164
165
  def can_add_observer?(attribute_name)
165
- has_instance_method?(attribute_name) || respond_to?("#{attribute_name}?") || @body_root.can_add_observer?(attribute_name)
166
+ has_instance_method?(attribute_name) || has_instance_method?("#{attribute_name}?") || @body_root.can_add_observer?(attribute_name)
166
167
  end
167
168
 
168
169
  def add_observer(observer, attribute_name)
@@ -174,12 +175,12 @@ module Glimmer
174
175
  end
175
176
 
176
177
  def has_attribute?(attribute_name, *args)
177
- respond_to?(attribute_setter(attribute_name), args) ||
178
+ has_instance_method?(attribute_setter(attribute_name)) ||
178
179
  @body_root.has_attribute?(attribute_name, *args)
179
180
  end
180
181
 
181
182
  def set_attribute(attribute_name, *args)
182
- if respond_to?(attribute_setter(attribute_name), args)
183
+ if has_instance_method?(attribute_setter(attribute_name))
183
184
  send(attribute_setter(attribute_name), *args)
184
185
  else
185
186
  @body_root.set_attribute(attribute_name, *args)
@@ -188,7 +189,10 @@ module Glimmer
188
189
 
189
190
  # This method ensures it has an instance method not coming from Glimmer DSL
190
191
  def has_instance_method?(method_name)
191
- respond_to?(method_name) && !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb')
192
+ respond_to?(method_name) &&
193
+ !swt_widget.respond_to?(method_name) &&
194
+ !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') &&
195
+ !method(method_name)&.source_location&.first&.include?('glimmer/swt/widget_proxy.rb')
192
196
  end
193
197
 
194
198
  def get_attribute(attribute_name)
@@ -203,7 +207,6 @@ module Glimmer
203
207
  "#{attribute_name}="
204
208
  end
205
209
 
206
-
207
210
  def has_style?(style)
208
211
  (swt_style & SWT::SWTProxy[style]) == SWT::SWTProxy[style]
209
212
  end
@@ -229,12 +232,19 @@ module Glimmer
229
232
  end
230
233
  end
231
234
 
232
- def dispose
233
- body_root.dispose
234
- end
235
-
236
235
  def method_missing(method, *args, &block)
237
- body_root.send(method, *args, &block)
236
+ if can_handle_observation_request?(method)
237
+ handle_observation_request(method, &block)
238
+ else
239
+ body_root.send(method, *args, &block)
240
+ end
241
+ end
242
+
243
+ alias local_respond_to? respond_to?
244
+ def respond_to?(method, *args, &block)
245
+ super or
246
+ can_handle_observation_request?(method) or
247
+ body_root.respond_to?(method, *args, &block)
238
248
  end
239
249
 
240
250
  private
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-17 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.9.4
18
+ version: 0.10.1
19
19
  name: glimmer
20
20
  type: :runtime
21
21
  prerelease: false
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.4
26
+ version: 0.10.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
@@ -57,7 +57,7 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 0.8.2
60
+ version: 0.9.0
61
61
  name: puts_debuggerer
62
62
  type: :runtime
63
63
  prerelease: false
@@ -65,67 +65,67 @@ dependencies:
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.8.2
68
+ version: 0.9.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 1.2.4
74
+ version: 2.3.9
75
75
  - - "<"
76
76
  - !ruby/object:Gem::Version
77
- version: 2.0.0
78
- name: text-table
77
+ version: 3.0.0
78
+ name: jeweler
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 1.2.4
85
+ version: 2.3.9
86
86
  - - "<"
87
87
  - !ruby/object:Gem::Version
88
- version: 2.0.0
88
+ version: 3.0.0
89
89
  - !ruby/object:Gem::Dependency
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
- version: 1.0.0
94
+ version: 2.3.0
95
95
  - - "<"
96
96
  - !ruby/object:Gem::Version
97
- version: 2.0.0
98
- name: os
97
+ version: 3.0.0
98
+ name: logging
99
99
  type: :runtime
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - ">="
104
104
  - !ruby/object:Gem::Version
105
- version: 1.0.0
105
+ version: 2.3.0
106
106
  - - "<"
107
107
  - !ruby/object:Gem::Version
108
- version: 2.0.0
108
+ version: 3.0.0
109
109
  - !ruby/object:Gem::Dependency
110
110
  requirement: !ruby/object:Gem::Requirement
111
111
  requirements:
112
112
  - - ">="
113
113
  - !ruby/object:Gem::Version
114
- version: 2.0.5
114
+ version: 1.0.0
115
115
  - - "<"
116
116
  - !ruby/object:Gem::Version
117
- version: 3.0.0
118
- name: warbler
117
+ version: 2.0.0
118
+ name: os
119
119
  type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - ">="
124
124
  - !ruby/object:Gem::Version
125
- version: 2.0.5
125
+ version: 1.0.0
126
126
  - - "<"
127
127
  - !ruby/object:Gem::Version
128
- version: 3.0.0
128
+ version: 2.0.0
129
129
  - !ruby/object:Gem::Dependency
130
130
  requirement: !ruby/object:Gem::Requirement
131
131
  requirements:
@@ -151,41 +151,61 @@ dependencies:
151
151
  requirements:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
- version: 2.3.9
154
+ version: 6.2.1
155
155
  - - "<"
156
156
  - !ruby/object:Gem::Version
157
- version: 3.0.0
158
- name: jeweler
157
+ version: 7.0.0
158
+ name: rdoc
159
159
  type: :runtime
160
160
  prerelease: false
161
161
  version_requirements: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
- version: 2.3.9
165
+ version: 6.2.1
166
166
  - - "<"
167
167
  - !ruby/object:Gem::Version
168
- version: 3.0.0
168
+ version: 7.0.0
169
169
  - !ruby/object:Gem::Dependency
170
170
  requirement: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - ">="
173
173
  - !ruby/object:Gem::Version
174
- version: 6.2.1
174
+ version: 1.2.4
175
175
  - - "<"
176
176
  - !ruby/object:Gem::Version
177
- version: 7.0.0
178
- name: rdoc
177
+ version: 2.0.0
178
+ name: text-table
179
179
  type: :runtime
180
180
  prerelease: false
181
181
  version_requirements: !ruby/object:Gem::Requirement
182
182
  requirements:
183
183
  - - ">="
184
184
  - !ruby/object:Gem::Version
185
- version: 6.2.1
185
+ version: 1.2.4
186
186
  - - "<"
187
187
  - !ruby/object:Gem::Version
188
- version: 7.0.0
188
+ version: 2.0.0
189
+ - !ruby/object:Gem::Dependency
190
+ requirement: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 2.0.5
195
+ - - "<"
196
+ - !ruby/object:Gem::Version
197
+ version: 3.0.0
198
+ name: warbler
199
+ type: :runtime
200
+ prerelease: false
201
+ version_requirements: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: 2.0.5
206
+ - - "<"
207
+ - !ruby/object:Gem::Version
208
+ version: 3.0.0
189
209
  - !ruby/object:Gem::Dependency
190
210
  requirement: !ruby/object:Gem::Requirement
191
211
  requirements: