Class: Rediscover::Panel::SortedSetView
- Inherits:
-
Wx::Panel
- Object
- Wx::Panel
- Rediscover::Panel::SortedSetView
- Includes:
- KeyViewer, Wx
- Defined in:
- lib/rediscover/panel/sorted_set_view.rb
Instance Method Summary collapse
- #add ⇒ Object
-
#initialize(parent, key) ⇒ SortedSetView
constructor
A new instance of SortedSetView.
- #setup ⇒ Object
Methods included from KeyViewer
#do_on_close, #do_on_save, #on_close, #on_save
Constructor Details
#initialize(parent, key) ⇒ SortedSetView
Returns a new instance of SortedSetView.
7 8 9 10 11 12 13 14 15 |
# File 'lib/rediscover/panel/sorted_set_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
#add ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/rediscover/panel/sorted_set_view.rb', line 44 def add @add_dlg = TextEntryDialog.new(self, 'Enter a new element:', 'Add Element') if @add_dlg.show_modal == ID_OK @redis.zadd(@key, 0, @add_dlg.get_value) # TODO get a priority score @element_list.set_elements(@redis.zrange(@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 |
# File 'lib/rediscover/panel/sorted_set_view.rb', line 17 def setup members = @redis.zrange(@key, 0, -1) @sizer = BoxSizer.new(VERTICAL) set_sizer(@sizer) @key_label = StaticText.new(self, :label => "Key: #{@key}") @element_list = SortedSetElementList.new(self, @key, members) @element_list.on_save { do_on_save } @button_sizer = BoxSizer.new(HORIZONTAL) @add_button = Button.new(self, :label => 'Add Element') @add_button, :add @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(@add_button, :flag => ALL, :border => 2) @button_sizer.add_item(@close_button, :flag => ALL, :border => 2) end |