Class: Rediscover::Panel::ListView
- Inherits:
-
Wx::Panel
- Object
- Wx::Panel
- Rediscover::Panel::ListView
- Includes:
- KeyViewer, Wx
- Defined in:
- lib/rediscover/panel/list_view.rb
Instance Method Summary collapse
-
#initialize(parent, key) ⇒ ListView
constructor
A new instance of ListView.
- #pop(dir = :lpop) ⇒ Object
- #push(dir = :lpush) ⇒ Object
- #setup ⇒ Object
Methods included from KeyViewer
#do_on_close, #do_on_save, #on_close, #on_save
Constructor Details
#initialize(parent, key) ⇒ ListView
Returns a new instance of ListView.
7 8 9 10 11 12 13 14 15 |
# File 'lib/rediscover/panel/list_view.rb', line 7 def initialize(parent, key) @parent, @key = parent, key @redis = get_app.redis @logger = get_app.logger super(@parent, -1, :style => SUNKEN_BORDER) setup end |
Instance Method Details
#pop(dir = :lpop) ⇒ Object
55 56 57 58 59 |
# File 'lib/rediscover/panel/list_view.rb', line 55 def pop(dir = :lpop) @redis.send(dir, @key) @element_list.set_elements(@redis.lrange(@key, 0, -1)) do_on_save end |
#push(dir = :lpush) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/rediscover/panel/list_view.rb', line 61 def push(dir = :lpush) @add_dlg = TextEntryDialog.new(self, 'Enter a new element:', 'Add Element') if @add_dlg.show_modal == ID_OK @redis.send(dir, @key, @add_dlg.get_value) @element_list.set_elements(@redis.lrange(@key, 0, -1)) do_on_save end end |
#setup ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rediscover/panel/list_view.rb', line 17 def setup members = @redis.lrange(@key, 0, -1) @sizer = BoxSizer.new(VERTICAL) set_sizer(@sizer) @key_label = StaticText.new(self, :label => "Key: #{@key}") @element_list = ListElementList.new(self, @key, members) @button_sizer = BoxSizer.new(HORIZONTAL) @lpush_button = Button.new(self, :label => 'Left Push') (@lpush_button) { push(:lpush) } @rpush_button = Button.new(self, :label => 'Right Push') (@rpush_button) { push(:rpush) } @lpop_button = Button.new(self, :label => 'Left Pop') (@lpop_button) { pop(:lpop) } @rpop_button = Button.new(self, :label => 'Right Pop') (@rpop_button) { pop(:rpop) } @close_button = Button.new(self, :label => 'Close') @close_button, :do_on_close @sizer.add_item(@key_label, :flag => ALL, :border => 2) @sizer.add_item(@element_list, :proportion => 1, :flag => EXPAND|ALL, :border => 2) @sizer.add_item(@button_sizer) @button_sizer.add_item(@lpush_button, :flag => ALL, :border => 2) @button_sizer.add_item(@rpush_button, :flag => ALL, :border => 2) @button_sizer.add_item(@lpop_button, :flag => ALL, :border => 2) @button_sizer.add_item(@rpop_button, :flag => ALL, :border => 2) @button_sizer.add_item(@close_button, :flag => ALL, :border => 2) end |