Class: DeletableListCell

Inherits:
Object
  • Object
show all
Includes:
JRubyFX
Defined in:
lib/jruby_visualizer/visualizer_main_app.rb

Overview

A ListCell that enables to delete the cell by a right click (ContextMenu)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDeletableListCell

Returns a new instance of DeletableListCell.



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/jruby_visualizer/visualizer_main_app.rb', line 37

def initialize
  delete_info_item = MenuItem.new('Delete Information')
  @delete_menu = ContextMenu.new(delete_info_item)
  delete_info_item.on_action do
    items = list_view.items
    info_string = get_string
    if items.include?(info_string)
      items.remove_all(info_string)
    end
  end
end

Instance Attribute Details

#delete_menuObject (readonly)

Returns the value of attribute delete_menu.



35
36
37
# File 'lib/jruby_visualizer/visualizer_main_app.rb', line 35

def delete_menu
  @delete_menu
end

Instance Method Details

#updateItem(item, empty) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/jruby_visualizer/visualizer_main_app.rb', line 49

def updateItem(item, empty)
  super(item, empty)

  if empty
    set_text(nil)
    set_graphic(nil)
  else
    set_text(get_string)
    set_graphic(nil)
    set_context_menu(@delete_menu)
  end
end