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, 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
-
#editor ⇒ Object
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, #cursor, #disposed?, #enabled, #focus, #font, #foreground, #menu, #menu_requested, #menu_x, #menu_y, #parent, #path, #rendered
Instance Method Summary collapse
- #dom ⇒ Object
- #editable? ⇒ Boolean
- #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_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, #dispose, #dom_element, #effective_observation_request_to_event_mapping, #event_handling_suspended?, #event_listener_proxies, for, #get_data, #handle_javascript_observation_request, #handle_observation_request, #has_style?, #id, #id=, #listener_dom_element, #listener_path, #listeners, #listeners_for, max_id_number_for, max_id_numbers, #method_missing, #name, next_id_number_for, #observation_requests, #parent_dom_element, #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, #selector, #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) ⇒ TableColumnProxy
Returns a new instance of TableColumnProxy.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 26 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Glimmer::SWT::WidgetProxy
Instance Attribute Details
#editor ⇒ Object
Returns the value of attribute editor.
22 23 24 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 22 def editor @editor end |
#no_sort ⇒ Object (readonly) Also known as: no_sort?
Returns the value of attribute no_sort.
22 23 24 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 22 def no_sort @no_sort end |
#sort_block ⇒ Object
Returns the value of attribute sort_block.
21 22 23 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 21 def sort_block @sort_block end |
#sort_by_block ⇒ Object
Returns the value of attribute sort_by_block.
21 22 23 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 21 def sort_by_block @sort_by_block end |
#sort_property ⇒ Object
Returns the value of attribute sort_property.
22 23 24 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 22 def sort_property @sort_property end |
#text ⇒ Object
Returns the value of attribute text.
22 23 24 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 22 def text @text end |
#width ⇒ Object
Returns the value of attribute width.
22 23 24 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 22 def width @width end |
Instance Method Details
#dom ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 101 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 |
#editable? ⇒ Boolean
83 84 85 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 83 def editable? !@editor&.include?(:none) end |
#element ⇒ Object
64 65 66 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 64 def element 'th' end |
#observation_request_to_event_mapping ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 87 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
60 61 62 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 60 def parent_path parent.columns_path end |
#redraw_sort_direction ⇒ Object
46 47 48 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 46 def redraw_sort_direction sort_icon_dom_element.attr('class', sort_icon_class) end |
#sort_direction ⇒ Object
42 43 44 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 42 def sort_direction parent.sort_direction if parent.sort_column == self end |
#sort_icon_class ⇒ Object
68 69 70 71 72 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 68 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
74 75 76 |
# File 'lib/glimmer/swt/table_column_proxy.rb', line 74 def sort_icon_dom_element dom_element.find('.sort-direction') end |