Class: Glimmer::SWT::TabItemProxy

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

Constant Summary

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS

Instance Attribute Summary collapse

Attributes inherited from CompositeProxy

#layout

Attributes inherited from WidgetProxy

#args, #background, #children, #enabled, #font, #foreground, #parent, #path

Instance Method Summary collapse

Methods inherited from WidgetProxy

#add_child, #add_css_class, #add_css_classes, #add_observer, #apply_property_type_converters, #build_dom, #can_handle_observation_request?, #clear_css_classes, #content, #css_classes, #dispose, #dom_element, #element, for, #handle_observation_request, #has_style?, #id, #id=, #listener_dom_element, max_id_number_for, max_id_numbers, #name, next_id_number_for, #parent_dom_element, #parent_path, #property_type_converters, #remove_css_class, #remove_css_classes, #render, reset_max_id_numbers!, #set_attribute, #style_element, underscored_widget_name, widget_class, widget_exists?, #widget_property_listener_installers

Methods included from PropertyOwner

#attribute_getter, #attribute_setter, #get_attribute, #set_attribute

Constructor Details

#initialize(parent, args) ⇒ TabItemProxy

Returns a new instance of TabItemProxy.



9
10
11
12
13
14
15
16
17
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 9

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

Instance Attribute Details

#content_visibleObject (readonly)

Returns the value of attribute content_visible.



7
8
9
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 7

def content_visible
  @content_visible
end

#textObject

Returns the value of attribute text.



7
8
9
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 7

def text
  @text
end

Instance Method Details

#domObject

This contains the tab content



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

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



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

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

#listener_pathObject



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

def listener_path
  tab_path
end

#observation_request_to_event_mappingObject



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

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

#selectorObject



36
37
38
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 36

def selector
  super + '-tab'
end

#showObject



19
20
21
22
23
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 19

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



65
66
67
68
69
70
71
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 65

def tab_dom
  @tab_dom ||= html {
    button(id: tab_id, class: "tab") {
      @text
    }
  }.to_s
end

#tab_dom_elementObject



56
57
58
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 56

def tab_dom_element
  Document.find(tab_path)
end

#tab_idObject



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

def tab_id
  id + '-tab'
end

#tab_pathObject



52
53
54
# File 'lib/glimmer/swt/tab_item_proxy.rb', line 52

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