class TkInspect::ClassBrowser::RootComponent

Attributes

class_browser[RW]

Public Instance Methods

browse_by_changed(e) click to toggle source
# File lib/tk_inspect/class_browser/root_component.rb, line 75
def browse_by_changed(e)
  @class_browser.browsing_method = e.sender.value
  @class_browser_comp.data_source = @class_browser.class_data_source
  @class_browser.select_class_path([])
  @class_browser_comp.selected_path = []
  @module_method_browser_component.selected_path = []
  @class_browser_comp.regenerate
  @module_method_browser_component.regenerate
end
class_selected(e) click to toggle source
# File lib/tk_inspect/class_browser/root_component.rb, line 47
def class_selected(e)
  @class_browser.select_class_path(e.data_object.selected_path)
  @module_method_browser_component.selected_path = []
  @module_method_browser_component.regenerate
end
filter_changed(e) click to toggle source
# File lib/tk_inspect/class_browser/root_component.rb, line 65
def filter_changed(e)
  return if class_browser.class_data_source.class_filter == e.sender.s_value
  class_browser.class_data_source.class_filter = e.sender.s_value
  @class_browser.select_class_path([])
  @class_browser_comp.selected_path = []
  @module_method_browser_component.selected_path = []
  @class_browser_comp.regenerate
  @module_method_browser_component.regenerate
end
module_method_selected(e) click to toggle source
# File lib/tk_inspect/class_browser/root_component.rb, line 53
def module_method_selected(e)
  path = e.data_object.selected_path || []
  module_name = path[0]
  method_name = path[1]
  code, line, file = @class_browser.code_for_method(method_name)
  @code.method_name = method_name
  @code.code = code
  @code.method_line = line
  @code.filename = file
  @code.update
end
render(p, parent_component) click to toggle source
# File lib/tk_inspect/class_browser/root_component.rb, line 8
def render(p, parent_component)
  p.vframe(sticky: 'nsew', x_flex: 1, y_flex: 1) do |vf|
    vf.hframe(padding: "12", sticky: 'nsew', x_flex: 1, y_flex: 0) do |hf|
      hf.hframe(sticky: 'nw') do |f|
        f.label(text: "Browse by: ")
        f.radio_set(value: "hierarchy", on_change: :browse_by_changed) do |rs|
          rs.radio_button(text: "Class hierarchy", value: 'hierarchy')
          rs.radio_button(text: "Namespaces", value: 'namespaces')
        end
      end
      hf.hframe(sticky: 'ne', x_flex: 1) do |f|
        f.label(text: "Filter")
        f.entry(value: class_browser.class_data_source.class_filter, on_change: :filter_changed)
      end
    end
    vf.vpaned(sticky: 'nsew', x_flex: 1, y_flex: 1) do |vp|
      @class_browser_comp = vp.insert_component(TkComponent::BrowserComponent, self,
                                                data_source: class_browser.class_data_source,
                                                selected_path: class_browser.selected_class_path,
                                                paned: true,
                                                sticky: 'nsew', x_flex: 1, y_flex: 1) do |bc|
        bc.on_event'PathChanged', ->(e) { class_selected(e) }
      end
      @module_method_browser_component = vp.insert_component(TkComponent::RBrowserComponent, self,
                                                             data_source: class_browser.module_method_data_source,
                                                             paned: true,
                                                             max_columns: 2,
                                                             sticky: 'nsew', x_flex: 1, y_flex: 1) do |bc|
        bc.on_event'PathChanged', ->(e) { module_method_selected(e) }
      end
      @code = vp.insert_component(CodeComponent, self, sticky: 'nsew', x_flex: 1, y_flex: 1)
    end
  end
end
show_current_selection() click to toggle source
# File lib/tk_inspect/class_browser/root_component.rb, line 43
def show_current_selection
  @class_browser_comp.show_current_selection
end