Class: Rediscover::Panel::Browser

Inherits:
Wx::SplitterWindow
  • Object
show all
Includes:
Wx
Defined in:
lib/rediscover/panel/browser.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Browser

Returns a new instance of Browser.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rediscover/panel/browser.rb', line 6

def initialize(parent)
  @parent = parent
  super(@parent, -1)

  @redis = get_app.redis
  @logger = get_app.logger

  @key_list_panel = Panel::KeyList.new(self)
  @key_list_panel.on_edit { |key, type, item| edit(key, type, item)}

  init(@key_list_panel) # just show the key list initially
end

Instance Method Details

#edit(key, type, item) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/rediscover/panel/browser.rb', line 19

def edit(key, type, item)
  unsplit(@view_panel) if @view_panel

  @view_panel = get_view_panel(key, type)
  @view_panel.on_save { @key_list_panel.refresh(item) }
  @view_panel.on_close { unsplit(@view_panel) }

  split_horizontally(@key_list_panel, @view_panel)
end

#get_view_panel(key, type) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/rediscover/panel/browser.rb', line 29

def get_view_panel(key, type)
  case type
    when 'string' then return Panel::StringView.new(self, key)
    when 'set' then return Panel::SetView.new(self, key)
    when 'zset' then return Panel::SortedSetView.new(self, key)
    when 'list' then return Panel::ListView.new(self, key)
  end
end

#on_status_change(&block) ⇒ Object



38
39
40
# File 'lib/rediscover/panel/browser.rb', line 38

def on_status_change(&block)
  @key_list_panel.on_status_change { |status| block.call(status) }
end