Class: CWM::Table
- Inherits:
-
CustomWidget
- Object
- AbstractWidget
- CustomWidget
- CWM::Table
- Defined in:
- library/cwm/src/lib/cwm/table.rb
Overview
Represents Table widget
Instance Attribute Summary
Attributes inherited from AbstractWidget
#handle_all_events, #widget_id
Instance Method Summary collapse
-
#cell(*args) ⇒ Object
protected
helper to create icon term.
-
#change_cell(id, column_number, cell_content) ⇒ Object
Replaces content of single cell.
-
#change_items(items_list) ⇒ Object
change list on fly with argument.
-
#contents ⇒ Object
Resulting table as YUI term.
-
#header ⇒ Object
return array of String or Yast::Term which is used as headers for table it can use e.g.
-
#icon(path) ⇒ Object
protected
helper to create icon term.
-
#item(*args) ⇒ Object
protected
helper to create a TableItem.
-
#items ⇒ Array<TableItem, Array>
Array with the table content.
-
#multiselection? ⇒ Boolean
protected
helper to say if table have multiselection.
-
#sort_key(value) ⇒ Object
protected
helper to create sort-key term.
-
#value ⇒ Array<Object>, Object
gets id of selected item in table or array of ids if multiselection option is used.
-
#value=(id) ⇒ Object
sets id of selected item(-s) in table.
Methods inherited from CustomWidget
#cwm_contents, #cwm_definition, #find_ids, #ids_in_contents
Methods inherited from AbstractWidget
#cleanup, #cwm_definition, #disable, #displayed?, #enable, #enabled?, #focus, #fun_ref, #handle, #help, #init, #label, #my_event?, #opt, #refresh_help, #store, #validate, widget_type=
Instance Method Details
#cell(*args) ⇒ Object (protected)
Please see difference between Cell
and cell
. The first one is
used in queries to pick exact cell, but later is used for content of cell.
For reasons ask libyui authors.
helper to create icon term
145 146 147 |
# File 'library/cwm/src/lib/cwm/table.rb', line 145 def cell(*args) Yast::Term.new(:cell, *args) end |
#change_cell(id, column_number, cell_content) ⇒ Object
more efficient for bigger tables then changing everything with #change_items
Replaces content of single cell
107 108 109 |
# File 'library/cwm/src/lib/cwm/table.rb', line 107 def change_cell(id, column_number, cell_content) Yast::UI.ChangeWidget(Id(), Cell(id, column_number), cell_content) end |
#change_items(items_list) ⇒ Object
items and change_items is consistent with ItemsSelection mixin, just format of items is different due to nature of Table content.
change list on fly with argument. Useful when content of widget is changed.
84 85 86 |
# File 'library/cwm/src/lib/cwm/table.rb', line 84 def change_items(items_list) Yast::UI.ChangeWidget(Id(), :Items, format_items(items_list)) end |
#contents ⇒ Object
used mainly to pass it CWM.
Resulting table as YUI term.
113 114 115 116 117 118 119 120 121 |
# File 'library/cwm/src/lib/cwm/table.rb', line 113 def contents opt_args = respond_to?(:opt, true) ? opt : [] Table( Id(), Opt(*opt_args), Header(*header), format_items(items) ) end |
#header ⇒ Object
return array of String or Yast::Term which is used as headers for table it can use e.g. align Left/Center/Right
43 |
# File 'library/cwm/src/lib/cwm/table.rb', line 43 abstract_method :header |
#icon(path) ⇒ Object (protected)
helper to create icon term
127 128 129 |
# File 'library/cwm/src/lib/cwm/table.rb', line 127 def icon(path) Yast::Term.new(:icon, path) end |
#item(*args) ⇒ Object (protected)
Not to be confused with the UI shortcut Item
helper to create a CWM::TableItem
155 156 157 |
# File 'library/cwm/src/lib/cwm/table.rb', line 155 def item(*args) TableItem.new(*args) end |
#items ⇒ Array<TableItem, Array>
default value is empty array. It is useful when computation expensive content need to be set. In such case, it is better to keep empty items to quickly show table and then in #init call #change_items method, so it will be filled when all widgets are at place and just filling its content.
Array with the table content
Each element can be a CWM::TableItem or an Array. The helper #item can be used to easily create CWM::TableItem objects.
If it's an array, the row contains no nested elements. The first element represents
the id of the row and the rest is used as data for its cells. Those can be e.g. terms.
Then it has to be enclosed in cell
term.
76 77 78 |
# File 'library/cwm/src/lib/cwm/table.rb', line 76 def items [] end |
#multiselection? ⇒ Boolean (protected)
helper to say if table have multiselection
160 161 162 163 164 |
# File 'library/cwm/src/lib/cwm/table.rb', line 160 def multiselection? return false unless respond_to?(:opt, true) opt.include?(:multiSelection) end |
#sort_key(value) ⇒ Object (protected)
helper to create sort-key term
133 134 135 |
# File 'library/cwm/src/lib/cwm/table.rb', line 133 def sort_key(value) Yast::Term.new(:sortKey, value) end |
#value ⇒ Array<Object>, Object
gets id of selected item in table or array of ids if multiselection option is used
90 91 92 93 |
# File 'library/cwm/src/lib/cwm/table.rb', line 90 def value val = Yast::UI.QueryWidget(Id(), :SelectedItems) multiselection? ? val : val.first end |
#value=(id) ⇒ Object
sets id of selected item(-s) in table
98 99 100 |
# File 'library/cwm/src/lib/cwm/table.rb', line 98 def value=(id) Yast::UI.ChangeWidget(Id(), :SelectedItems, Array(id)) end |