Class: Glimmer::SWT::TableColumnProxy
- Inherits:
-
WidgetProxy
- Object
- WidgetProxy
- Glimmer::SWT::TableColumnProxy
- Includes:
- Glimmer
- Defined in:
- lib/glimmer/swt/table_column_proxy.rb
Constant Summary collapse
- STYLE =
<<~CSS th.table-column { background: rgb(246, 246, 246); text-align: left; padding: 5px; } th.table-column .sort-direction { float: right; } CSS
Constants inherited from WidgetProxy
WidgetProxy::DEFAULT_INITIALIZERS
Instance Attribute Summary collapse
-
#editor ⇒ Object
readonly
Returns the value of attribute editor.
-
#no_sort ⇒ Object
(also: #no_sort?)
readonly
Returns the value of attribute no_sort.
-
#sort_block ⇒ Object
Returns the value of attribute sort_block.
-
#sort_by_block ⇒ Object
Returns the value of attribute sort_by_block.
-
#sort_property ⇒ Object
Returns the value of attribute sort_property.
-
#text ⇒ Object
Returns the value of attribute text.
-
#width ⇒ Object
Returns the value of attribute width.
Attributes inherited from WidgetProxy
#args, #background, #children, #enabled, #focus, #font, #foreground, #parent, #path
Instance Method Summary collapse
- #dom ⇒ Object
- #element ⇒ Object
-
#initialize(parent, args, block) ⇒ TableColumnProxy
constructor
A new instance of TableColumnProxy.
- #observation_request_to_event_mapping ⇒ Object
- #parent_path ⇒ Object
- #redraw_sort_direction ⇒ Object
- #sort_direction ⇒ Object
- #sort_icon_class ⇒ Object
- #sort_icon_dom_element ⇒ Object
Methods inherited from WidgetProxy
#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, for, #handle_observation_request, #has_style?, #id, #id=, #listener_dom_element, #listener_path, max_id_number_for, max_id_numbers, #name, next_id_number_for, #parent_dom_element, #post_add_content, #post_initialize_child, #property_type_converters, #remove_css_class, #remove_css_classes, #render, reset_max_id_numbers!, #selector, #set_attribute, #set_focus, #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, block) ⇒ TableColumnProxy
Returns a new instance of TableColumnProxy.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 25 def initialize(parent, args, block) @no_sort = args.delete(:no_sort) super(parent, args, block) unless no_sort? content { { |event| parent.sort_by_column!(self) } } end end |
Instance Attribute Details
#editor ⇒ Object (readonly)
Returns the value of attribute editor.
21 22 23 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 21 def editor @editor end |
#no_sort ⇒ Object (readonly) Also known as: no_sort?
Returns the value of attribute no_sort.
21 22 23 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 21 def no_sort @no_sort end |
#sort_block ⇒ Object
Returns the value of attribute sort_block.
20 21 22 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 20 def sort_block @sort_block end |
#sort_by_block ⇒ Object
Returns the value of attribute sort_by_block.
20 21 22 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 20 def sort_by_block @sort_by_block end |
#sort_property ⇒ Object
Returns the value of attribute sort_property.
21 22 23 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 21 def sort_property @sort_property end |
#text ⇒ Object
Returns the value of attribute text.
21 22 23 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 21 def text @text end |
#width ⇒ Object
Returns the value of attribute width.
21 22 23 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 21 def width @width end |
Instance Method Details
#dom ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 91 def dom table_column_text = text table_column_id = id table_column_id_style = "width: #{width}px;" table_column_css_classes = css_classes table_column_css_classes << name @dom ||= html { th(id: table_column_id, style: table_column_id_style, class: table_column_css_classes.to_a.join(' ')) { span {table_column_text} span(class: sort_icon_class) } }.to_s end |
#element ⇒ Object
63 64 65 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 63 def element 'th' end |
#observation_request_to_event_mapping ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 77 def observation_request_to_event_mapping { 'on_widget_selected' => { event: 'click', event_handler: -> (event_listener) { -> (event) { event_listener.call(event) redraw_sort_direction } } }, } end |
#parent_path ⇒ Object
59 60 61 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 59 def parent_path parent.columns_path end |
#redraw_sort_direction ⇒ Object
45 46 47 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 45 def redraw_sort_direction sort_icon_dom_element.attr('class', sort_icon_class) end |
#sort_direction ⇒ Object
41 42 43 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 41 def sort_direction parent.sort_direction if parent.sort_column == self end |
#sort_icon_class ⇒ Object
67 68 69 70 71 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 67 def sort_icon_class @sort_icon_class = 'sort-direction' @sort_icon_class += (sort_direction == SWTProxy[:up] ? ' ui-icon ui-icon-caret-1-n' : ' ui-icon ui-icon-caret-1-s') unless sort_direction.nil? @sort_icon_class end |
#sort_icon_dom_element ⇒ Object
73 74 75 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 73 def sort_icon_dom_element dom_element.find('.sort-direction') end |