Class: Glimmer::SWT::Custom::RefinedTable
- Inherits:
-
Object
- Object
- Glimmer::SWT::Custom::RefinedTable
show all
- Includes:
- UI::CustomWidget
- Defined in:
- lib/glimmer/swt/custom/refined_table.rb
Overview
RefinedTable is a customization of Table with support for Filtering/Pagination
Instance Attribute Summary collapse
#body_root, #options, #parent, #parent_proxy, #swt_style, #swt_widget
Instance Method Summary
collapse
add_custom_widget_namespaces_for, #add_observer, after_body, #async_exec, #attribute_setter, before_body, body, #can_add_observer?, #can_handle_observation_request?, #children_owner, #content, custom_widget_namespaces, def_option_attr_accessors, #disposed?, flyweight_custom_widget_classes, for, #get_attribute, #handle_observation_request, #has_attribute?, #has_instance_method?, #has_style?, #initialize, keyword, #local_respond_to?, namespaces_for_class, #observer_registrations, option, options, #post_add_content, #post_initialize_child, reset_custom_widget_namespaces, #set_attribute, #shell_proxy, shortcut_keyword, #sync_exec, #timer_exec
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/glimmer/swt/custom/refined_table.rb', line 133
def method_missing(method_name, *args, &block)
dsl_mode = @dsl_mode || args.last.is_a?(Hash) && args.last[:dsl]
if dsl_mode
args.pop if args.last.is_a?(Hash) && args.last[:dsl]
super(method_name, *args, &block)
elsif @table_proxy&.respond_to?(method_name, *args, &block)
@table_proxy&.send(method_name, *args, &block)
else
super
end
end
|
Instance Attribute Details
#page_text_proxy ⇒ Object
Returns the value of attribute page_text_proxy.
36
37
38
|
# File 'lib/glimmer/swt/custom/refined_table.rb', line 36
def page_text_proxy
@page_text_proxy
end
|
#refined_model_array ⇒ Object
Returns the value of attribute refined_model_array.
35
36
37
|
# File 'lib/glimmer/swt/custom/refined_table.rb', line 35
def refined_model_array
@refined_model_array
end
|
#table_proxy ⇒ Object
Returns the value of attribute table_proxy.
36
37
38
|
# File 'lib/glimmer/swt/custom/refined_table.rb', line 36
def table_proxy
@table_proxy
end
|
Instance Method Details
#corrected_page(initial_page_value = nil) ⇒ Object
159
160
161
162
163
164
165
|
# File 'lib/glimmer/swt/custom/refined_table.rb', line 159
def corrected_page(initial_page_value = nil)
correct_page = initial_page_value || page
correct_page = [correct_page, page_count].min
correct_page = [correct_page, 1].max
correct_page = (model_array&.count.to_i > 0) ? (correct_page > 0 ? correct_page : 1) : 0
correct_page
end
|
#first_page ⇒ Object
167
168
169
|
# File 'lib/glimmer/swt/custom/refined_table.rb', line 167
def first_page
(model_array&.count.to_i > 0) ? 1 : 0
end
|
#last_page ⇒ Object
171
172
173
|
# File 'lib/glimmer/swt/custom/refined_table.rb', line 171
def last_page
page_count
end
|
#page_count ⇒ Object
155
156
157
|
# File 'lib/glimmer/swt/custom/refined_table.rb', line 155
def page_count
(model_array && (model_array.count / per_page.to_f).ceil) || 0
end
|
#paginate ⇒ Object
175
176
177
178
|
# File 'lib/glimmer/swt/custom/refined_table.rb', line 175
def paginate
self.page = corrected_page(page)
self.refined_model_array = model_array[(page - 1) * per_page, per_page]
end
|
#respond_to?(method_name, *args, &block) ⇒ Boolean
145
146
147
148
149
150
151
152
153
|
# File 'lib/glimmer/swt/custom/refined_table.rb', line 145
def respond_to?(method_name, *args, &block)
dsl_mode = @dsl_mode || args.last.is_a?(Hash) && args.last[:dsl]
if dsl_mode
args = args[0...-1] if args.last.is_a?(Hash) && args.last[:dsl]
super(method_name, *args, &block)
else
super || @table_proxy&.respond_to?(method_name, *args, &block)
end
end
|
#table_block=(block) ⇒ Object
129
130
131
|
# File 'lib/glimmer/swt/custom/refined_table.rb', line 129
def table_block=(block)
@table_proxy.content(&block)
end
|