Class: Glimmer::SWT::TabItemProxy

Inherits:
CompositeProxy show all
Includes:
Glimmer
Defined in:
lib/glimmer/swt/tab_item_proxy.rb

Direct Known Subclasses

CTabItemProxy

Constant Summary

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS, WidgetProxy::JS_KEY_CODE_TO_SWT_KEY_CODE_MAP, WidgetProxy::JS_LOCATION_TO_SWT_KEY_LOCATION_MAP, WidgetProxy::SWT_CURSOR_TO_CSS_CURSOR_MAP

Instance Attribute Summary collapse

Attributes inherited from WidgetProxy

#args, #background, #children, #cursor, #disposed?, #enabled, #focus, #font, #foreground, #menu, #menu_requested, #menu_x, #menu_y, #parent, #path, #rendered

Instance Method Summary collapse

Methods inherited from CompositeProxy

#background_image, #background_image=, #default_layout, #get_layout, #layout=, #layout​, #pack

Methods inherited from WidgetProxy

#add_content_on_render, #add_css_class, #add_css_classes, #add_observer, #apply_property_type_converters, #attach, #build_dom, #can_handle_observation_request?, #clear_css_classes, #content, #content_on_render_blocks, #css_classes, #default_observation_request_to_event_mapping, #dialog_ancestor, #dom_element, #effective_observation_request_to_event_mapping, #element, #event_handling_suspended?, #event_listener_proxies, for, #get_data, #handle_javascript_observation_request, #handle_observation_request, #has_style?, #id, #id=, #listener_dom_element, #listeners, #listeners_for, max_id_number_for, max_id_numbers, #method_missing, #name, next_id_number_for, #observation_requests, #parent_dom_element, #parent_path, #parents, #post_add_content, #post_dispose_child, #post_initialize_child, #print, #property_type_converters, #reattach, #remove_all_listeners, #remove_css_class, #remove_css_classes, #remove_event_listener_proxies, #render, reset_max_id_numbers!, #resume_event_handling, #set_attribute, #set_data, #set_focus, #shell, #skip_content_on_render_blocks?, #style_element, #suspend_event_handling, #swt_data, #swt_widget, underscored_widget_name, widget_class, widget_exists?, widget_handling_listener, #widget_property_listener_installers

Methods included from PropertyOwner

#attribute_getter, #attribute_setter, #get_attribute, #set_attribute

Constructor Details

#initialize(parent, args, block) ⇒ TabItemProxy

Returns a new instance of TabItemProxy.



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

def initialize(parent, args, block)
  super(parent, args, block)
  content {
    on_widget_selected {
      @parent.hide_all_tab_content
      show
    }
  }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::SWT::WidgetProxy

Instance Attribute Details

#content_visibleObject (readonly)

Returns the value of attribute content_visible.



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

def content_visible
  @content_visible
end

#imageObject

Returns the value of attribute image.



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

def image
  @image
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

#tool_tip_textObject

Returns the value of attribute tool_tip_text.



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

def tool_tip_text
  @tool_tip_text
end

Instance Method Details

#disposeObject



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 70

def dispose
  tab_index = parent.children.to_a.index(self)
  tab_dom_element.remove
  super
  if @content_visible
    @content_visible = false
    parent.hide_all_tab_content
    tab_to_show = parent.children.to_a[tab_index]
    tab_to_show ||= parent.children.to_a[tab_index - 1]
    tab_to_show&.show
  end
end

#domObject

This contains the tab content



122
123
124
125
126
127
128
129
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 122

def dom
  tab_item_id = id
  tab_item_class_string = [name, 'hide'].join(' ')
  @dom ||= html {
    div(id: tab_item_id, class: tab_item_class_string) {
    }
  }.to_s
end

#hideObject



46
47
48
49
50
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 46

def hide
  @content_visible = false
  dom_element.add_class('hide')
  tab_dom_element.remove_class('selected')
end

#listener_pathObject



95
96
97
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 95

def listener_path
  tab_path
end

#observation_request_to_event_mappingObject



87
88
89
90
91
92
93
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 87

def observation_request_to_event_mapping
  {
    'on_widget_selected' => {
      event: 'click'
    },
  }
end

#selectorObject



83
84
85
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 83

def selector
  super + '-tab'
end

#showObject



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

def show
  @content_visible = true
  dom_element.remove_class('hide')
  tab_dom_element.add_class('selected')
end

#tab_domObject

This contains the clickable tab area with tab names



112
113
114
115
116
117
118
119
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 112

def tab_dom
  @tab_dom ||= html {
    a(href: '#', id: tab_id, class: "tab") {
      img {}
      span { @text }
    }
  }.to_s
end

#tab_dom_elementObject



103
104
105
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 103

def tab_dom_element
  Document.find(tab_path)
end

#tab_idObject



107
108
109
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 107

def tab_id
  id + '-tab'
end

#tab_pathObject



99
100
101
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 99

def tab_path
  "#{parent.tabs_path} > ##{tab_id}"
end