Class: Clevic::ComboBox

Inherits:
Object show all
Defined in:
lib/clevic/swing/combo_delegate.rb

Overview

all this just to format a display item… .… and work around various other Swing stupidities

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field) ⇒ ComboBox

Returns a new instance of ComboBox.



11
12
13
14
# File 'lib/clevic/swing/combo_delegate.rb', line 11

def initialize( field )
  super()
  @field = field
end

Instance Attribute Details

#delegateObject

Returns the value of attribute delegate.



9
10
11
# File 'lib/clevic/swing/combo_delegate.rb', line 9

def delegate
  @delegate
end

#typingObject (readonly)

set to true by processKeyBinding when a character key is pressed. Used by the autocomplete code.



24
25
26
# File 'lib/clevic/swing/combo_delegate.rb', line 24

def typing
  @typing
end

Instance Method Details

#configureEditor(combo_box_editor, item) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/clevic/swing/combo_delegate.rb', line 26

def configureEditor( combo_box_editor, item )
  value =
  if @field.related_class && item.is_a?( @field.related_class )
    @field.transform_attribute( item )
  else
    item
  end

  combo_box_editor.item = value
end

#no_insert=(bool) ⇒ Object

For Clevic::ComboDelegate to call



17
18
19
20
# File 'lib/clevic/swing/combo_delegate.rb', line 17

def no_insert=( bool )
  # Swing doesn't have combo policies like Qt.
  # From what I can see, anyway.
end

#processKeyBinding(key_stroke, key_event, condition, pressed) ⇒ Object

Get the first keystroke when editing starts, and make sure it’s entered into the combo box text edit component, if it’s not an action key.



39
40
41
42
43
44
45
# File 'lib/clevic/swing/combo_delegate.rb', line 39

def processKeyBinding( key_stroke, key_event, condition, pressed )
  if key_event.typed? && !key_event.action_key?
    editor.editor_component.text = java.lang.Character.new( key_event.key_char ).toString
  end
  @typing = !key_event.action_key?
  super
end