Class: Glimmer::SWT::MessageBoxProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/glimmer/swt/message_box_proxy.rb

Overview

Proxy for org.eclipse.swt.widgets.Shell

Follows the Proxy Design Pattern

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, style) ⇒ MessageBoxProxy

Returns a new instance of MessageBoxProxy.



16
17
18
19
20
# File 'lib/glimmer/swt/message_box_proxy.rb', line 16

def initialize(parent, style)
  parent = parent.swt_widget if parent.respond_to?(:swt_widget) && parent.swt_widget.is_a?(Shell)
  @temporary_parent = parent = Glimmer::SWT::ShellProxy.new.swt_widget if parent.nil?
  @swt_widget = MessageBox.new(parent, style)
end

Instance Attribute Details

#swt_widgetObject (readonly)

Returns the value of attribute swt_widget.



14
15
16
# File 'lib/glimmer/swt/message_box_proxy.rb', line 14

def swt_widget
  @swt_widget
end

Instance Method Details

#attribute_getter(attribute_name) ⇒ Object



33
34
35
# File 'lib/glimmer/swt/message_box_proxy.rb', line 33

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)



29
30
31
# File 'lib/glimmer/swt/message_box_proxy.rb', line 29

def attribute_setter(attribute_name)
  "set#{attribute_name.to_s.camelcase(:upper)}"
end

#get_attribute(attribute_name) ⇒ Object



45
46
47
# File 'lib/glimmer/swt/message_box_proxy.rb', line 45

def get_attribute(attribute_name)
  @swt_widget.send(attribute_getter(attribute_name))
end

#has_attribute?(attribute_name, *args) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/glimmer/swt/message_box_proxy.rb', line 37

def has_attribute?(attribute_name, *args)
  @swt_widget.respond_to?(attribute_setter(attribute_name), args)
end

#openObject



22
23
24
25
# File 'lib/glimmer/swt/message_box_proxy.rb', line 22

def open
  @swt_widget.open
  @temporary_parent&.dispose
end

#set_attribute(attribute_name, *args) ⇒ Object



41
42
43
# File 'lib/glimmer/swt/message_box_proxy.rb', line 41

def set_attribute(attribute_name, *args)
  @swt_widget.send(attribute_setter(attribute_name), *args) unless @swt_widget.send(attribute_getter(attribute_name)) == args.first
end