Class: CWM::ReplacePoint
- Inherits:
-
CustomWidget
- Object
- AbstractWidget
- CustomWidget
- CWM::ReplacePoint
- Defined in:
- library/cwm/src/lib/cwm/replace_point.rb
Overview
Placeholder widget that is used to replace content on demand. The most important method is #replace which allows switching content
Instance Attribute Summary
Attributes inherited from AbstractWidget
#handle_all_events, #widget_id
Instance Method Summary collapse
-
#cleanup ⇒ Object
Passes to replace point content.
- #contents ⇒ UITerm
-
#handle(event) ⇒ Object
Passes to replace point content.
-
#help ⇒ Object
Dynamic help, that compute help of current displayed widgets.
-
#init ⇒ Object
switches to initial widget.
-
#initialize(widget:, id: "_placeholder") ⇒ ReplacePoint
constructor
placeholder needed to be in dialog.
-
#replace(widget) ⇒ Object
Replaces content with different widget.
-
#store ⇒ Object
Passes to replace point content.
-
#validate ⇒ Object
Passes to replace point content.
Methods inherited from CustomWidget
#cwm_contents, #cwm_definition, #find_ids, #ids_in_contents
Methods inherited from AbstractWidget
#cwm_definition, #disable, #displayed?, #enable, #enabled?, #focus, #fun_ref, #label, #my_event?, #opt, #refresh_help, widget_type=
Constructor Details
#initialize(widget:, id: "_placeholder") ⇒ ReplacePoint
placeholder needed to be in dialog. Parameter type is limited by component system
15 16 17 18 19 20 21 |
# File 'library/cwm/src/lib/cwm/replace_point.rb', line 15 def initialize(widget:, id: "_placeholder") super() self.handle_all_events = true self. = id @widget = end |
Instance Method Details
#cleanup ⇒ Object
Passes to replace point content
73 74 75 |
# File 'library/cwm/src/lib/cwm/replace_point.rb', line 73 def cleanup Yast::CWM.cleanupWidgets(@widgets_hash) end |
#contents ⇒ UITerm
24 25 26 27 28 29 30 |
# File 'library/cwm/src/lib/cwm/replace_point.rb', line 24 def contents # In `contents` we must use an Empty Term, otherwise CWMClass # would see an {AbstractWidget} and handle events itself, # which result in double calling of methods like {handle} or {store} for # initial widget. ReplacePoint(Id(), Empty(Id("___cwm_rp_empty"))) end |
#handle(event) ⇒ Object
Passes to replace point content
53 54 55 |
# File 'library/cwm/src/lib/cwm/replace_point.rb', line 53 def handle(event) Yast::CWM.handleWidgets(@widgets_hash, event) end |
#help ⇒ Object
Dynamic help, that compute help of current displayed widgets
58 59 60 |
# File 'library/cwm/src/lib/cwm/replace_point.rb', line 58 def help Yast::CWM.MergeHelps(@widgets_hash) end |
#init ⇒ Object
switches to initial widget
33 34 35 |
# File 'library/cwm/src/lib/cwm/replace_point.rb', line 33 def init replace(@widget) end |
#replace(widget) ⇒ Object
Replaces content with different widget. All its events are properly handled.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'library/cwm/src/lib/cwm/replace_point.rb', line 40 def replace() = Yast::CWM.([]) @widgets_hash = .map { |w| Yast::CWM.prepareWidget(w.cwm_definition) } # VBox as CWM ignore top level term and process string inside it, # so non-container widgets have problem and its value is processed term = Yast::CWM.PrepareDialog(VBox(.), @widgets_hash) Yast::UI.ReplaceWidget(Id(), term) Yast::CWM.initWidgets(@widgets_hash) @widget = refresh_help end |