Class: CWM::CustomWidget
- Inherits:
-
AbstractWidget
- Object
- AbstractWidget
- CWM::CustomWidget
- Defined in:
- library/cwm/src/lib/cwm/custom_widget.rb
Overview
A custom widget that has its UI content defined in the method #contents. Useful mainly when a specialized widget including more subwidgets should be reusable at more places.
Direct Known Subclasses
Page, Pager, ProgressBar, ReplacePoint, ServiceWidget, Table, Tree
Instance Attribute Summary
Attributes inherited from AbstractWidget
#handle_all_events, #widget_id
Instance Method Summary collapse
-
#contents ⇒ WidgetTerm
Must be defined by subclasses.
-
#cwm_contents ⇒ StringTerm
protected
return contents converted to format understandable by CWM module Basically it replace instance of AbstractWidget by its widget_id.
- #cwm_definition ⇒ WidgetHash
- #find_ids(term) ⇒ Object protected
- #ids_in_contents ⇒ Object protected
Methods inherited from AbstractWidget
#cleanup, #disable, #displayed?, #enable, #enabled?, #focus, #fun_ref, #handle, #help, #init, #label, #my_event?, #opt, #refresh_help, #store, #validate, widget_type=
Instance Method Details
#contents ⇒ WidgetTerm
Must be defined by subclasses
35 |
# File 'library/cwm/src/lib/cwm/custom_widget.rb', line 35 abstract_method :contents |
#cwm_contents ⇒ StringTerm (protected)
return contents converted to format understandable by CWM module Basically it replace instance of AbstractWidget by its widget_id
51 52 53 54 55 |
# File 'library/cwm/src/lib/cwm/custom_widget.rb', line 51 def cwm_contents Yast.import "CWM" Yast::CWM.(contents) end |
#cwm_definition ⇒ WidgetHash
38 39 40 41 42 43 44 |
# File 'library/cwm/src/lib/cwm/custom_widget.rb', line 38 def cwm_definition res = { "custom_widget" => cwm_contents } res["handle_events"] = ids_in_contents unless handle_all_events super.merge(res) end |
#find_ids(term) ⇒ Object (protected)
61 62 63 64 65 66 67 68 69 70 71 |
# File 'library/cwm/src/lib/cwm/custom_widget.rb', line 61 def find_ids(term) term.each_with_object([]) do |arg, res| next unless arg.is_a? Yast::Term if arg.value == :id res << arg.params[0] else res.concat(find_ids(arg)) end end end |
#ids_in_contents ⇒ Object (protected)
57 58 59 |
# File 'library/cwm/src/lib/cwm/custom_widget.rb', line 57 def ids_in_contents find_ids(contents) << end |