Class: Glimmer::SWT::MessageBoxProxy
- Inherits:
-
Object
- Object
- Glimmer::SWT::MessageBoxProxy
show all
- Defined in:
- lib/glimmer/swt/message_box_proxy.rb
Overview
Proxy for org.eclipse.swt.widgets.MessageBox
Follows the Proxy Design Pattern
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of MessageBoxProxy.
37
38
39
40
41
42
43
|
# File 'lib/glimmer/swt/message_box_proxy.rb', line 37
def initialize(parent, style)
if parent.nil?
@temporary_parent = parent = Glimmer::SWT::ShellProxy.new.swt_widget
end
@swt_widget = MessageBox.new(parent, style)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/glimmer/swt/message_box_proxy.rb', line 83
def method_missing(method, *args, &block)
DisplayProxy.instance.auto_exec do
swt_widget.send(method, *args, &block)
end
rescue => e
begin
super
rescue Exception => inner_error
Glimmer::Config.logger.error {"Neither MessageBoxProxy nor #{swt_widget.class.name} can handle the method ##{method}"}
Glimmer::Config.logger.error {e.full_message}
raise inner_error
end
end
|
Instance Attribute Details
Returns the value of attribute swt_widget.
35
36
37
|
# File 'lib/glimmer/swt/message_box_proxy.rb', line 35
def swt_widget
@swt_widget
end
|
Instance Method Details
#attribute_getter(attribute_name) ⇒ Object
63
64
65
|
# File 'lib/glimmer/swt/message_box_proxy.rb', line 63
def attribute_getter(attribute_name)
"get#{attribute_name.to_s.camelcase(:upper)}"
end
|
#attribute_setter(attribute_name) ⇒ Object
TODO refactor the following methods to put in a JavaBean mixin or somethin (perhaps contribute to OSS project too)
59
60
61
|
# File 'lib/glimmer/swt/message_box_proxy.rb', line 59
def attribute_setter(attribute_name)
"set#{attribute_name.to_s.camelcase(:upper)}"
end
|
#content(&block) ⇒ Object
#get_attribute(attribute_name) ⇒ Object
77
78
79
80
81
|
# File 'lib/glimmer/swt/message_box_proxy.rb', line 77
def get_attribute(attribute_name)
DisplayProxy.instance.auto_exec do
@swt_widget.send(attribute_getter(attribute_name))
end
end
|
#has_attribute?(attribute_name, *args) ⇒ Boolean
67
68
69
|
# File 'lib/glimmer/swt/message_box_proxy.rb', line 67
def has_attribute?(attribute_name, *args)
@swt_widget.respond_to?(attribute_setter(attribute_name), args)
end
|
#open ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/glimmer/swt/message_box_proxy.rb', line 45
def open
DisplayProxy.instance.auto_exec do
@swt_widget.open.tap do |result|
@temporary_parent&.dispose
end
end
end
|
#respond_to?(method, *args, &block) ⇒ Boolean
97
98
99
100
|
# File 'lib/glimmer/swt/message_box_proxy.rb', line 97
def respond_to?(method, *args, &block)
super ||
swt_widget.respond_to?(method, *args, &block)
end
|
#set_attribute(attribute_name, *args) ⇒ Object
71
72
73
74
75
|
# File 'lib/glimmer/swt/message_box_proxy.rb', line 71
def set_attribute(attribute_name, *args)
DisplayProxy.instance.auto_exec do
@swt_widget.send(attribute_setter(attribute_name), *args) unless @swt_widget.send(attribute_getter(attribute_name)) == args.first
end
end
|