Class: Glimmer::SWT::TabItemProxy

Inherits:
WidgetProxy show all
Defined in:
lib/glimmer/swt/tab_item_proxy.rb

Overview

Proxy for org.eclipse.swt.widgets.TabItem

Functions differently from other widget proxies.

Glimmer instantiates an SWT Composite alongside the SWT TabItem and returns it for ‘#swt_widget` to allow adding widgets into it.

In order to get the SWT TabItem object, one must call ‘#swt_tab_item`.

Behind the scenes, this creates a tab item widget proxy separately from a composite that is set as the control of the tab item and ‘#swt_widget`.

In order to retrieve the tab item widget proxy, one must call ‘#widget_proxy`

Follows the Proxy Design Pattern

Constant Summary

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS, WidgetProxy::DEFAULT_STYLES

Instance Attribute Summary collapse

Attributes inherited from WidgetProxy

#swt_widget

Instance Method Summary collapse

Methods inherited from WidgetProxy

#add_observer, #async_exec, #can_add_observer?, #can_handle_observation_request?, #content, #extract_args, #handle_observation_request, #has_style?, #pack_same_size, #remove_observer, swt_widget_class_for, #sync_exec, widget_exists?, #widget_property_listener_installers

Methods included from DataBinding::ObservableWidget

#method_missing

Constructor Details

#initialize(parent, style, &contents) ⇒ TabItemProxy

Returns a new instance of TabItemProxy.



25
26
27
28
29
30
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 25

def initialize(parent, style, &contents)
  super("composite", parent, style, &contents)
  @widget_proxy = SWT::WidgetProxy.new('tab_item', parent, style)
  @swt_tab_item = @widget_proxy.swt_widget
  @widget_proxy.swt_widget.control = self.swt_widget
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::DataBinding::ObservableWidget

Instance Attribute Details

#swt_tab_itemObject (readonly)

Returns the value of attribute swt_tab_item.



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

def swt_tab_item
  @swt_tab_item
end

#widget_proxyObject (readonly)

Returns the value of attribute widget_proxy.



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

def widget_proxy
  @widget_proxy
end

Instance Method Details

#disposeObject



58
59
60
61
62
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 58

def dispose
  swt_tab_item.setControl(nil)
  swt_widget.dispose
  swt_tab_item.dispose
end

#get_attribute(attribute_name) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 50

def get_attribute(attribute_name)
  if attribute_name.to_s == "text"
    @swt_tab_item.getText
  else
    super(attribute_name)
  end
end

#has_attribute?(attribute_name, *args) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 32

def has_attribute?(attribute_name, *args)
  if attribute_name.to_s == "text"
    true
  else
    super(attribute_name, *args)
  end
end

#set_attribute(attribute_name, *args) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 40

def set_attribute(attribute_name, *args)
  attribute_name
  if attribute_name.to_s == "text"
    text_value = args[0]
    @swt_tab_item.setText text_value
  else
    super(attribute_name, *args)
  end
end