Class: Rediscover::Panel::KeyList
- Inherits:
-
Wx::Panel
- Object
- Wx::Panel
- Rediscover::Panel::KeyList
- Extended by:
- Forwardable
- Includes:
- Wx
- Defined in:
- lib/rediscover/panel/key_list.rb
Instance Method Summary collapse
- #filter ⇒ Object
-
#initialize(parent) ⇒ KeyList
constructor
A new instance of KeyList.
- #on_status_change(&block) ⇒ Object
- #refresh(item = nil) ⇒ Object
- #setup_key_browser ⇒ Object
- #setup_key_shortcuts ⇒ Object
- #setup_sizer ⇒ Object
- #setup_tool_bar ⇒ Object
Constructor Details
#initialize(parent) ⇒ KeyList
Returns a new instance of KeyList.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rediscover/panel/key_list.rb', line 9 def initialize(parent) @parent = parent super(@parent, -1) @redis = get_app.redis @logger = get_app.logger @key_pattern = '*' setup_sizer setup_key_browser setup_key_shortcuts end |
Instance Method Details
#filter ⇒ Object
75 76 77 78 79 |
# File 'lib/rediscover/panel/key_list.rb', line 75 def filter @key_pattern = @filter_textbox.get_value.strip @key_pattern = '*' if @key_pattern.nil? or @key_pattern == '' refresh end |
#on_status_change(&block) ⇒ Object
81 82 83 |
# File 'lib/rediscover/panel/key_list.rb', line 81 def on_status_change(&block) @key_list.on_status_change { |status| block.call(status) } end |
#refresh(item = nil) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/rediscover/panel/key_list.rb', line 67 def refresh(item = nil) if(item) @key_list.refresh_item(item) else @key_list.update end end |
#setup_key_browser ⇒ Object
60 61 62 63 64 65 |
# File 'lib/rediscover/panel/key_list.rb', line 60 def setup_key_browser @key_list = KeyListCtrl.new(self) @sizer.add(@key_list, 1, EXPAND) @key_list.on_get_keys { @redis.keys(@key_pattern).sort } @key_list.update end |
#setup_key_shortcuts ⇒ Object
56 57 58 |
# File 'lib/rediscover/panel/key_list.rb', line 56 def setup_key_shortcuts evt_key_up { |event| refresh if event.get_key_code == K_F5 } end |
#setup_sizer ⇒ Object
23 24 25 26 |
# File 'lib/rediscover/panel/key_list.rb', line 23 def setup_sizer @sizer = BoxSizer.new(VERTICAL) set_sizer(@sizer) end |
#setup_tool_bar ⇒ Object
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 54 |
# File 'lib/rediscover/panel/key_list.rb', line 28 def @tool_bar_sizer = BoxSizer.new(HORIZONTAL) @sizer.add_item(@tool_bar_sizer) @add_button = Button.new(self, ID_ADD) (@add_button) do create_key_frame = Rediscover::Frame::CreateKey.new(self) create_key_frame.on_create { refresh } end @refresh_button = Button.new(self, ID_REFRESH) @refresh_button, :refresh # filter input and button @filter_textbox = TextCtrl.new(self, :style => TE_PROCESS_ENTER, :size => Size.new(200, -1)) evt_text_enter @filter_textbox, :filter # filter when enter is pressed in the textbox @filter_button = Button.new(self, :label => 'Filter') @filter_button, :filter # filter when button is pressed # add elements to tool bar @tool_bar_sizer.add_item(@add_button, :flag => ALL, :border => 1) @tool_bar_sizer.add_item(@refresh_button, :flag => ALL, :border => 1) @tool_bar_sizer.add_item(@filter_textbox, :flag => ALL, :border => 1) @tool_bar_sizer.add_item(@filter_button, :flag => ALL, :border => 1) end |