Class: Redcar::MyPlugin::EditMyPluginCommand

Inherits:
Command show all
Defined in:
plugins/my_plugin/lib/my_plugin.rb

Overview

Command to open a new window, make the project my_plugin and open this file.

Constant Summary

Constants included from Observable

Observable::ASPECTS

Instance Attribute Summary

Attributes inherited from Command

#error

Instance Method Summary (collapse)

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



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'plugins/my_plugin/lib/my_plugin.rb', line 30

def execute
  # Open the project in a new window
  Project::Manager.open_project_for_path("plugins/my_plugin")
  
  # Create a new edittab
  tab  = Redcar.app.focussed_window.new_tab(Redcar::EditTab)
  
  # A FileMirror's job is to wrap up the file in an interface that the Document understands.
  mirror = Project::FileMirror.new(File.join(Redcar.root, "plugins", "my_plugin", "lib", "my_plugin.rb"))
  tab.edit_view.document.mirror = mirror

  # Make sure the tab is focussed and the user can't undo the insertion of the document text
  tab.edit_view.reset_undo
  tab.focus
end