Class: Redcar::Project::RevealInProjectCommand

Inherits:
Redcar::ProjectCommand show all
Defined in:
plugins/project/lib/project/commands.rb

Constant Summary

Constants included from Observable

Observable::ASPECTS

Instance Attribute Summary

Attributes inherited from Command

#error

Instance Method Summary (collapse)

Methods inherited from Redcar::ProjectCommand

#project

Methods inherited from Command

active_changed, #environment, inherited, #inspect, norecord, record?, #run

Methods included from Sensitive

#active?, #sensitivities, #sensitivity_names, #sensitize

Methods included from Observable

#add_listener, #notify_listeners, #remove_listener

Instance Method Details

- (Object) execute



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'plugins/project/lib/project/commands.rb', line 213

def execute
  if project
    tab = Redcar.app.focussed_window.focussed_notebook_tab
      if tab.is_a?(EditTab)
      return unless mirror = tab.edit_view.document.mirror and mirror.respond_to? :path
    else
      return
    end

    path = mirror.path
    tree = project.tree
    current = tree.tree_mirror.top
    while current.any?
      ancestor_node = current.detect {|node| path =~ /^#{node.path}($|\/)/ }
      return unless ancestor_node
      tree.expand(ancestor_node)
      current = ancestor_node.children
    end
    tree.select(ancestor_node)
    project.window.treebook.focus_tree(project.tree)
  end
end