Class: Glimmer::DataBinding::WidgetBinding
- Inherits:
-
Object
- Object
- Glimmer::DataBinding::WidgetBinding
- Includes:
- Glimmer, Observable, Observer
- Defined in:
- lib/glimmer/data_binding/widget_binding.rb
Constant Summary
Constants included from Glimmer
Instance Attribute Summary collapse
-
#model_binding ⇒ Object
readonly
Returns the value of attribute model_binding.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#widget ⇒ Object
readonly
Returns the value of attribute widget.
Instance Method Summary collapse
- #call(value) ⇒ Object
- #evaluate_property ⇒ Object
-
#initialize(widget, property, sync_exec: nil, async_exec: nil) ⇒ WidgetBinding
constructor
A new instance of WidgetBinding.
- #observe(*args) ⇒ Object
Methods included from Glimmer
Constructor Details
#initialize(widget, property, sync_exec: nil, async_exec: nil) ⇒ WidgetBinding
Returns a new instance of WidgetBinding.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/glimmer/data_binding/widget_binding.rb', line 36 def initialize(, property, sync_exec: nil, async_exec: nil) = @property = property @sync_exec = sync_exec @async_exec = async_exec SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @sync_exec, override_async_exec: @async_exec) do if .is_a?(Glimmer::SWT::WidgetProxy) && .respond_to?(:on_widget_disposed) . do |dispose_event| unless .shell_proxy.last_shell_closing? ..delete(self) deregister_all_observables end end end # TODO look into hooking on_shape_disposed without slowing down shapes in samples like Tetris end # TODO try to come up with a more comprehensive and cleaner solution to miscallenous objects like MessageBoxProxy with regards to @widget_proxy = .is_a?(Glimmer::SWT::WidgetProxy) ? : (.respond_to?(:body_root) ? .body_root : ) end |
Instance Attribute Details
#model_binding ⇒ Object (readonly)
Returns the value of attribute model_binding.
34 35 36 |
# File 'lib/glimmer/data_binding/widget_binding.rb', line 34 def model_binding @model_binding end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
34 35 36 |
# File 'lib/glimmer/data_binding/widget_binding.rb', line 34 def property @property end |
#widget ⇒ Object (readonly)
Returns the value of attribute widget.
34 35 36 |
# File 'lib/glimmer/data_binding/widget_binding.rb', line 34 def end |
Instance Method Details
#call(value) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/glimmer/data_binding/widget_binding.rb', line 66 def call(value) SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @sync_exec, override_async_exec: @async_exec) do if .respond_to?(:disposed?) && .disposed? unless .shell_proxy.last_shell_closing? ..delete(self) deregister_all_observables end return end # need the rescue false for a scenario with tree items not being equal to model objects raising an exception if @async_exec || !((value == evaluate_property) rescue false) # need the rescue false for a scenario with tree items not being equal to model objects raising an exception .set_attribute(@property, value) end end end |
#evaluate_property ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/glimmer/data_binding/widget_binding.rb', line 82 def evaluate_property if .respond_to?(:disposed?) && .disposed? unless .shell_proxy.last_shell_closing? ..delete(self) deregister_all_observables end return end .get_attribute(@property) end |
#observe(*args) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/glimmer/data_binding/widget_binding.rb', line 56 def observe(*args) if .respond_to?(:widget_bindings) # TODO try to come up with a more comprehensive and cleaner solution to miscallenous objects like MessageBoxProxy with regards to the following code # assumes only one observation @model_binding = args.first if args.size == 1 . << self end super end |