Class: Clevic::SetDelegate
- Inherits:
-
ComboDelegate
- Object
- Qt::ItemDelegate
- Delegate
- ComboDelegate
- Clevic::SetDelegate
- Includes:
- SimplestDelegate
- Defined in:
- lib/clevic/qt/set_delegate.rb,
lib/clevic/swing/set_delegate.rb,
lib/clevic/delegates/set_delegate.rb
Overview
A Combo box which allows a set of values. May or may not be restricted to the set. TODO this should be a module
Instance Attribute Summary
Attributes inherited from ComboDelegate
Attributes inherited from Delegate
Instance Method Summary collapse
-
#initialize(field) ⇒ SetDelegate
constructor
options must contain a :set => [ … ] to specify the set of values.
- #item_to_editor(item) ⇒ Object
- #needs_combo? ⇒ Boolean
-
#population ⇒ Object
Items here could either be single values, or two-value arrays (from a hash-like set), so use key as db value and value as display value.
- #restricted? ⇒ Boolean
Methods included from SimplestDelegate
Methods inherited from ComboDelegate
#allow_null?, #autocomplete, #combo_class, #configure_editable, #configure_prefix, #createEditor, #create_combo_box, #display_for, #dump_editor_state, #empty_set?, #filter_prefix, #framework_setup, #full_edit, #getListCellRendererComponent, #hint_string, #if_empty_message, #init_component, #is_combo?, #line_editor, #minimal_edit, #needs_pre_selection?, #repopulate, #setEditorData, #setModelData, #translate_from_editor_text, #updateEditorGeometry, #value
Methods inherited from Delegate
#attribute, #editorEvent, #entity_class, #full_edit, #inspect, #is_combo?, #minimal_edit, #native, #needs_pre_selection?, #show_message, #updateEditorGeometry
Methods included from FieldValuer
#attribute_value, #attribute_value=, #display_value, #edit_value, #edit_value=, #find_related, #raw_value, #text_value=, #tooltip, valuer, #valuer, #writer
Constructor Details
#initialize(field) ⇒ SetDelegate
options must contain a :set => [ … ] to specify the set of values.
10 11 12 13 |
# File 'lib/clevic/delegates/set_delegate.rb', line 10 def initialize( field ) raise "SetDelegate must have a :set in options" if field.set.nil? super end |
Instance Method Details
#item_to_editor(item) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/clevic/swing/set_delegate.rb', line 8 def item_to_editor( item ) if item.is_a?( Array ) puts "#{__FILE__}:#{__LINE__}:probably can't deal with item: #{item.inspect}" # this is a hash-like set, so use key as db value # and value as display value class << item def toString; last; end end else class << item def toString; self; end end end end |
#needs_combo? ⇒ Boolean
15 16 17 |
# File 'lib/clevic/delegates/set_delegate.rb', line 15 def needs_combo? true end |
#population ⇒ Object
Items here could either be single values, or two-value arrays (from a hash-like set), so use key as db value and value as display value
26 27 28 |
# File 'lib/clevic/delegates/set_delegate.rb', line 26 def population field.set_for( entity ) end |
#restricted? ⇒ Boolean
19 20 21 |
# File 'lib/clevic/delegates/set_delegate.rb', line 19 def restricted? field.restricted || false end |