redcar 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +24 -0
- data/Rakefile +85 -2
- data/lib/json/CHANGES +166 -0
- data/lib/json/COPYING +58 -0
- data/lib/json/GPL +340 -0
- data/lib/json/README +358 -0
- data/lib/json/Rakefile +292 -0
- data/lib/json/TODO +1 -0
- data/lib/json/VERSION +1 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
- data/lib/json/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
- data/lib/json/benchmarks/generator2_benchmark.rb +222 -0
- data/lib/json/benchmarks/generator_benchmark.rb +224 -0
- data/lib/json/benchmarks/ohai.json +1216 -0
- data/lib/json/benchmarks/ohai.ruby +1 -0
- data/lib/json/benchmarks/parser2_benchmark.rb +251 -0
- data/lib/json/benchmarks/parser_benchmark.rb +259 -0
- data/lib/json/bin/edit_json.rb +9 -0
- data/lib/json/bin/prettify_json.rb +75 -0
- data/lib/json/data/example.json +1 -0
- data/lib/json/data/index.html +38 -0
- data/lib/json/data/prototype.js +4184 -0
- data/lib/json/ext/json/ext/generator/extconf.rb +16 -0
- data/lib/json/ext/json/ext/generator/generator.c +1323 -0
- data/lib/json/ext/json/ext/generator/generator.h +170 -0
- data/lib/json/ext/json/ext/parser/extconf.rb +15 -0
- data/lib/json/ext/json/ext/parser/parser.c +1935 -0
- data/lib/json/ext/json/ext/parser/parser.h +71 -0
- data/lib/json/ext/json/ext/parser/parser.rl +792 -0
- data/lib/json/install.rb +26 -0
- data/lib/json/lib/json.rb +10 -0
- data/lib/json/lib/json/Array.xpm +21 -0
- data/lib/json/lib/json/FalseClass.xpm +21 -0
- data/lib/json/lib/json/Hash.xpm +21 -0
- data/lib/json/lib/json/Key.xpm +73 -0
- data/lib/json/lib/json/NilClass.xpm +21 -0
- data/lib/json/lib/json/Numeric.xpm +28 -0
- data/lib/json/lib/json/String.xpm +96 -0
- data/lib/json/lib/json/TrueClass.xpm +21 -0
- data/lib/json/lib/json/add/core.rb +148 -0
- data/lib/json/lib/json/add/rails.rb +58 -0
- data/lib/json/lib/json/common.rb +397 -0
- data/lib/json/lib/json/editor.rb +1371 -0
- data/lib/json/lib/json/ext.rb +15 -0
- data/lib/json/lib/json/json.xpm +1499 -0
- data/lib/json/lib/json/pure.rb +77 -0
- data/lib/json/lib/json/pure/generator.rb +452 -0
- data/lib/json/lib/json/pure/parser.rb +307 -0
- data/lib/json/lib/json/version.rb +8 -0
- data/lib/json/tests/fixtures/fail1.json +1 -0
- data/lib/json/tests/fixtures/fail10.json +1 -0
- data/lib/json/tests/fixtures/fail11.json +1 -0
- data/lib/json/tests/fixtures/fail12.json +1 -0
- data/lib/json/tests/fixtures/fail13.json +1 -0
- data/lib/json/tests/fixtures/fail14.json +1 -0
- data/lib/json/tests/fixtures/fail18.json +1 -0
- data/lib/json/tests/fixtures/fail19.json +1 -0
- data/lib/json/tests/fixtures/fail2.json +1 -0
- data/lib/json/tests/fixtures/fail20.json +1 -0
- data/lib/json/tests/fixtures/fail21.json +1 -0
- data/lib/json/tests/fixtures/fail22.json +1 -0
- data/lib/json/tests/fixtures/fail23.json +1 -0
- data/lib/json/tests/fixtures/fail24.json +1 -0
- data/lib/json/tests/fixtures/fail25.json +1 -0
- data/lib/json/tests/fixtures/fail27.json +2 -0
- data/lib/json/tests/fixtures/fail28.json +2 -0
- data/lib/json/tests/fixtures/fail3.json +1 -0
- data/lib/json/tests/fixtures/fail4.json +1 -0
- data/lib/json/tests/fixtures/fail5.json +1 -0
- data/lib/json/tests/fixtures/fail6.json +1 -0
- data/lib/json/tests/fixtures/fail7.json +1 -0
- data/lib/json/tests/fixtures/fail8.json +1 -0
- data/lib/json/tests/fixtures/fail9.json +1 -0
- data/lib/json/tests/fixtures/pass1.json +56 -0
- data/lib/json/tests/fixtures/pass15.json +1 -0
- data/lib/json/tests/fixtures/pass16.json +1 -0
- data/lib/json/tests/fixtures/pass17.json +1 -0
- data/lib/json/tests/fixtures/pass2.json +1 -0
- data/lib/json/tests/fixtures/pass26.json +1 -0
- data/lib/json/tests/fixtures/pass3.json +6 -0
- data/lib/json/tests/test_json.rb +361 -0
- data/lib/json/tests/test_json_addition.rb +162 -0
- data/lib/json/tests/test_json_encoding.rb +68 -0
- data/lib/json/tests/test_json_fixtures.rb +34 -0
- data/lib/json/tests/test_json_generate.rb +122 -0
- data/lib/json/tests/test_json_rails.rb +144 -0
- data/lib/json/tests/test_json_unicode.rb +76 -0
- data/lib/json/tools/fuzz.rb +139 -0
- data/lib/json/tools/server.rb +61 -0
- data/lib/redcar.rb +5 -3
- data/lib/redcar/runner.rb +1 -5
- data/lib/redcar_quick_start.rb +2 -7
- data/plugins/application/features/support/env.rb +6 -1
- data/plugins/application/lib/application/command/history.rb +5 -0
- data/plugins/application/lib/application/dialog.rb +1 -1
- data/plugins/application_swt/lib/application_swt.rb +0 -1
- data/plugins/application_swt/lib/application_swt/html_tab.rb +4 -2
- data/plugins/application_swt/lib/application_swt/menu.rb +3 -1
- data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +4 -0
- data/plugins/core/lib/core.rb +1 -0
- data/plugins/core/lib/core/has_spi.rb +10 -0
- data/plugins/edit_view/features/new_tab.feature +0 -1
- data/plugins/edit_view/features/step_definitions/tab_steps.rb +1 -1
- data/plugins/edit_view/lib/edit_view.rb +13 -0
- data/plugins/edit_view/lib/edit_view/document/command.rb +1 -1
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +4 -0
- data/plugins/html_view/assets/redcar.css +2 -1
- data/plugins/html_view/lib/html_view.rb +19 -6
- data/plugins/html_view/lib/html_view/html_tab.rb +2 -2
- data/plugins/project/lib/project.rb +11 -0
- data/plugins/project/lib/project/dir_controller.rb +252 -2
- data/plugins/project/lib/project/dir_mirror.rb +53 -5
- data/plugins/project/lib/project/manager.rb +5 -1
- data/plugins/project/views/bulk_rename.html.erb +162 -0
- data/plugins/redcar/redcar.rb +22 -2
- data/plugins/runnables/icons/cog.png +0 -0
- data/plugins/runnables/lib/runnables.rb +99 -0
- data/plugins/runnables/plugin_no_load.rb +9 -0
- data/plugins/tree/lib/tree.rb +61 -0
- data/plugins/tree/lib/tree/controller.rb +53 -4
- data/plugins/tree/lib/tree/mirror.rb +56 -16
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +250 -24
- metadata +2700 -2604
- data/plugins/application_swt/lib/application_swt/notebook/drag_and_drop_listener.rb +0 -71
|
@@ -8,6 +8,9 @@ module Redcar
|
|
|
8
8
|
Project.window_projects.values
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
# Returns the project in the given window
|
|
12
|
+
# @param [Window] window
|
|
13
|
+
# @return Project or nil
|
|
11
14
|
def self.in_window(window)
|
|
12
15
|
Project.window_projects[window]
|
|
13
16
|
end
|
|
@@ -124,7 +127,8 @@ module Redcar
|
|
|
124
127
|
#
|
|
125
128
|
# @param [String] path the path of the directory to view
|
|
126
129
|
def self.open_project_for_path(path)
|
|
127
|
-
win
|
|
130
|
+
win = Redcar.app.focussed_window
|
|
131
|
+
win = Redcar.app.new_window if !win or Manager.in_window(win)
|
|
128
132
|
project = Project.new(path).tap do |p|
|
|
129
133
|
p.open(win) if p.ready?
|
|
130
134
|
end
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
|
|
2
|
+
<script type="text/javascript" src="file://<%= Redcar::HtmlView.jquery_path %>"></script>
|
|
3
|
+
<link rel="stylesheet" href="file://<%= Redcar::HtmlView.default_css_path %>" type="text/css" media="screen">
|
|
4
|
+
|
|
5
|
+
<h3>Bulk Rename</h3>
|
|
6
|
+
<form id="refresh-form" action="controller/submit">
|
|
7
|
+
<table>
|
|
8
|
+
<tr>
|
|
9
|
+
<td>Match:</td><td> <input name="match-pattern" id="match-pattern" value="<%= match_pattern %>" /></td>
|
|
10
|
+
<td>Replace:</td><td> <input name="replace-pattern" id="replace-pattern" value="<%= replace_pattern %>" /></td>
|
|
11
|
+
<td><input type="submit" id="refresh"></td>
|
|
12
|
+
</tr>
|
|
13
|
+
</table>
|
|
14
|
+
</form>
|
|
15
|
+
|
|
16
|
+
<table>
|
|
17
|
+
<tr>
|
|
18
|
+
<th>Old</th>
|
|
19
|
+
<th>New</th>
|
|
20
|
+
</tr>
|
|
21
|
+
<% pairs.each do |node, new_name| %>
|
|
22
|
+
<tr>
|
|
23
|
+
<td><%= File.basename(node.path) %></td>
|
|
24
|
+
<td class="name-slot"><%= new_name %></td>
|
|
25
|
+
<td class="extra-info"></td>
|
|
26
|
+
</tr>
|
|
27
|
+
<% end %>
|
|
28
|
+
</table>
|
|
29
|
+
<br />
|
|
30
|
+
<hr />
|
|
31
|
+
<br />
|
|
32
|
+
<small><a class="show-examples">Show examples</a></small>
|
|
33
|
+
<div id="examples" style="display:none;" class="example-box">
|
|
34
|
+
<small><a class="hide-examples">Hide examples</a></small>
|
|
35
|
+
<br /><br />
|
|
36
|
+
<p>E.g.</p>
|
|
37
|
+
<table>
|
|
38
|
+
<tr>
|
|
39
|
+
<td>Match</td><td>Replace</td><td>From</td><td>To</td>
|
|
40
|
+
</tr>
|
|
41
|
+
<tr><td>E</td><td>XXXXX</td><td>README</td><td>RXXXXXADME</td></tr>
|
|
42
|
+
<tr><td>$</td><td>.md</td><td>README</td><td>README.md</td></tr>
|
|
43
|
+
</table>
|
|
44
|
+
</div>
|
|
45
|
+
<br />
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
<script language="javascript">
|
|
49
|
+
jQuery.fn.watch = function( id, fn ) {
|
|
50
|
+
|
|
51
|
+
return this.each(function(){
|
|
52
|
+
|
|
53
|
+
var self = this;
|
|
54
|
+
|
|
55
|
+
var oldVal = self[id];
|
|
56
|
+
$(self).data(
|
|
57
|
+
'watch_timer',
|
|
58
|
+
setInterval(function(){
|
|
59
|
+
if (self[id] !== oldVal) {
|
|
60
|
+
fn.call(self, id, oldVal, self[id]);
|
|
61
|
+
oldVal = self[id];
|
|
62
|
+
}
|
|
63
|
+
}, 100)
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
return self;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
jQuery.fn.unwatch = function( id ) {
|
|
70
|
+
return this.each(function(){
|
|
71
|
+
clearInterval( $(this).data('watch_timer') );
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
jQuery.fn.valuechange = function(fn) {
|
|
75
|
+
return this.bind('valuechange', fn);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
jQuery.event.special.valuechange = {
|
|
79
|
+
|
|
80
|
+
setup: function() {
|
|
81
|
+
|
|
82
|
+
jQuery(this).watch('value', function(){
|
|
83
|
+
jQuery.event.handle.call(this, {type:'valuechange'});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
teardown: function() {
|
|
89
|
+
jQuery(this).unwatch('value');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
BulkRename = {
|
|
95
|
+
disableForm: function() {
|
|
96
|
+
$("input#refresh").attr("disabled", true);
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
enableForm: function() {
|
|
100
|
+
$("input#refresh").attr("disabled", false);
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
updateNames: function(newNames) {
|
|
104
|
+
BulkRename.enableForm();
|
|
105
|
+
var nameSlots = $(".name-slot");
|
|
106
|
+
var extraSlots = $(".extra-info");
|
|
107
|
+
$.each(newNames, function(ix, a) {
|
|
108
|
+
var name = a[0];
|
|
109
|
+
var exists = a[1];
|
|
110
|
+
var legal = a[2];
|
|
111
|
+
$(nameSlots[ix]).html(name);
|
|
112
|
+
if (!legal) {
|
|
113
|
+
$(extraSlots[ix]).html("illegal filename");
|
|
114
|
+
BulkRename.disableForm();
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
if (exists) {
|
|
118
|
+
$(extraSlots[ix]).html("conflicts");
|
|
119
|
+
BulkRename.disableForm();
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
$(extraSlots[ix]).html("");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
init: function() {
|
|
129
|
+
$("#match-pattern").bind("valuechange", function(propName, oldVal, newVal) {
|
|
130
|
+
try {
|
|
131
|
+
var newNames = Controller.refresh($("#match-pattern").attr("value"), $("#replace-pattern").attr("value"));
|
|
132
|
+
BulkRename.updateNames(newNames);
|
|
133
|
+
} catch(e) {
|
|
134
|
+
alert(e.message);
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
$("#replace-pattern").bind("valuechange", function(propName, oldVal, newVal) {
|
|
138
|
+
try {
|
|
139
|
+
var newNames = Controller.refresh($("#match-pattern").attr("value"), $("#replace-pattern").attr("value"));
|
|
140
|
+
BulkRename.updateNames(newNames);
|
|
141
|
+
} catch(e) {
|
|
142
|
+
alert(e.message);
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
$(".show-examples").click(function() {
|
|
147
|
+
$("#examples").slideDown();
|
|
148
|
+
$(".show-examples").slideUp();
|
|
149
|
+
});
|
|
150
|
+
$(".hide-examples").click(function() {
|
|
151
|
+
$("#examples").slideUp();
|
|
152
|
+
$(".show-examples").slideDown();
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
BulkRename.init();
|
|
158
|
+
|
|
159
|
+
</script>
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
data/plugins/redcar/redcar.rb
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
+
|
|
1
2
|
module Redcar
|
|
3
|
+
def self.safely(text=nil)
|
|
4
|
+
if text == nil
|
|
5
|
+
text = caller[1]
|
|
6
|
+
end
|
|
7
|
+
begin
|
|
8
|
+
yield
|
|
9
|
+
rescue => e
|
|
10
|
+
message = "Error in: " + text
|
|
11
|
+
Application::Dialog.message_box(
|
|
12
|
+
message,
|
|
13
|
+
:type => :error, :buttons => :ok)
|
|
14
|
+
puts message
|
|
15
|
+
puts e.class.to_s + ": " + e.message
|
|
16
|
+
puts e.backtrace
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
2
20
|
module Top
|
|
3
21
|
class QuitCommand < Command
|
|
4
22
|
|
|
@@ -772,10 +790,10 @@ module Redcar
|
|
|
772
790
|
link "Ctrl+V", PasteCommand
|
|
773
791
|
link "Ctrl+D", DuplicateCommand
|
|
774
792
|
|
|
775
|
-
link "
|
|
793
|
+
link "Ctrl+Home", MoveTopCommand
|
|
776
794
|
link "Home", MoveHomeCommand
|
|
777
795
|
link "End", MoveEndCommand
|
|
778
|
-
link "
|
|
796
|
+
link "Ctrl+End", MoveBottomCommand
|
|
779
797
|
|
|
780
798
|
link "Ctrl+[", DecreaseIndentCommand
|
|
781
799
|
link "Ctrl+]", IncreaseIndentCommand
|
|
@@ -868,6 +886,8 @@ module Redcar
|
|
|
868
886
|
sub_menu "Project" do
|
|
869
887
|
item "Find File", Project::FindFileCommand
|
|
870
888
|
item "Refresh Directory", Project::RefreshDirectoryCommand
|
|
889
|
+
#separator
|
|
890
|
+
#item "Runnables", Runnables::ShowRunnables
|
|
871
891
|
end
|
|
872
892
|
sub_menu "Debug" do
|
|
873
893
|
item "Task Manager", TaskManager::OpenCommand
|
|
Binary file
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
|
|
2
|
+
module Redcar
|
|
3
|
+
class Runnables
|
|
4
|
+
|
|
5
|
+
class TreeMirror
|
|
6
|
+
include Redcar::Tree::Mirror
|
|
7
|
+
|
|
8
|
+
def initialize(project)
|
|
9
|
+
runnables = project.config_file(:runnables)
|
|
10
|
+
if runnables
|
|
11
|
+
@top = runnables.map do |name, info|
|
|
12
|
+
Runnable.new(name, info)
|
|
13
|
+
end
|
|
14
|
+
else
|
|
15
|
+
@top = [HelpItem.new]
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def title
|
|
20
|
+
"Runnables"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def top
|
|
24
|
+
@top
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class HelpItem
|
|
29
|
+
include Redcar::Tree::Mirror::NodeMirror
|
|
30
|
+
|
|
31
|
+
def text
|
|
32
|
+
"No runnables (HELP)"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class Runnable
|
|
37
|
+
include Redcar::Tree::Mirror::NodeMirror
|
|
38
|
+
|
|
39
|
+
def initialize(name, info)
|
|
40
|
+
@name = name
|
|
41
|
+
@info = info
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def text
|
|
45
|
+
@name
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def leaf?
|
|
49
|
+
@info[:command]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def icon
|
|
53
|
+
if leaf?
|
|
54
|
+
File.dirname(__FILE__) + "/../icons/cog.png"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def children
|
|
59
|
+
return [] if leaf?
|
|
60
|
+
|
|
61
|
+
@info.map do |name, info|
|
|
62
|
+
Runnable.new(name, info)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def command
|
|
67
|
+
@info[:command]
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
class TreeController
|
|
72
|
+
include Redcar::Tree::Controller
|
|
73
|
+
|
|
74
|
+
def initialize(project)
|
|
75
|
+
@project = project
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def activated(tree, node)
|
|
79
|
+
command = node.command
|
|
80
|
+
output = `#{command}`
|
|
81
|
+
tab = Redcar.app.focussed_window.new_tab(EditTab)
|
|
82
|
+
tab.edit_view.document.text = output
|
|
83
|
+
tab.title = node.text
|
|
84
|
+
tab.focus
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
class ShowRunnables < Redcar::Command
|
|
89
|
+
def execute
|
|
90
|
+
project = Project::Manager.in_window(win)
|
|
91
|
+
tree = Tree.new(
|
|
92
|
+
TreeMirror.new(project),
|
|
93
|
+
TreeController.new(project)
|
|
94
|
+
)
|
|
95
|
+
win.treebook.add_tree(tree)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
data/plugins/tree/lib/tree.rb
CHANGED
|
@@ -3,20 +3,81 @@ require 'tree/controller'
|
|
|
3
3
|
require 'tree/mirror'
|
|
4
4
|
|
|
5
5
|
module Redcar
|
|
6
|
+
# Pass classes implementing Redcar::Tree::Mirror and
|
|
7
|
+
# Redcar::Tree::Controller to Tree#new to create a tree. Pass to
|
|
8
|
+
# window.treebook.add_tree to open the Tree in a Window.
|
|
9
|
+
#
|
|
10
|
+
# Trees build up their contents by querying the Tree::Mirror. For
|
|
11
|
+
# instance, a simple tree containing the numbers 1 to 10 could be created
|
|
12
|
+
# like this:
|
|
13
|
+
#
|
|
14
|
+
# class CountMirror
|
|
15
|
+
# include Redcar::Tree::Mirror
|
|
16
|
+
#
|
|
17
|
+
# def top
|
|
18
|
+
# (1..10).map {|i| CountNode.new(i)}
|
|
19
|
+
# end
|
|
20
|
+
#
|
|
21
|
+
# class CountNode
|
|
22
|
+
# include Redcar::Tree::NodeMirror
|
|
23
|
+
#
|
|
24
|
+
# def initialize(i)
|
|
25
|
+
# @i = i
|
|
26
|
+
# end
|
|
27
|
+
#
|
|
28
|
+
# def text
|
|
29
|
+
# @i.to_s
|
|
30
|
+
# end
|
|
31
|
+
# end
|
|
32
|
+
# end
|
|
33
|
+
#
|
|
34
|
+
# tree = Tree.new(CountMirror.new)
|
|
35
|
+
# Redcar.app.focussed_window.treebook.add_tree(tree)
|
|
6
36
|
class Tree
|
|
7
37
|
include Redcar::Model
|
|
8
38
|
include Redcar::Observable
|
|
39
|
+
include Redcar::HasSPI
|
|
9
40
|
|
|
10
41
|
attr_reader :tree_mirror, :tree_controller
|
|
11
42
|
|
|
43
|
+
# @param [Tree::Mirror] an instance of a class including Tree::Mirror
|
|
44
|
+
# @param [Tree::Controller] an instance of a class including Tree::Controller
|
|
12
45
|
def initialize(tree_mirror, tree_controller=nil)
|
|
46
|
+
assert_interface(tree_mirror, Redcar::Tree::Mirror)
|
|
47
|
+
if tree_controller
|
|
48
|
+
assert_interface(tree_controller, Redcar::Tree::Controller)
|
|
49
|
+
end
|
|
13
50
|
@tree_mirror = tree_mirror
|
|
14
51
|
@tree_controller = tree_controller
|
|
15
52
|
end
|
|
16
53
|
|
|
54
|
+
# Refresh the tree by requerying the mirror from the top and
|
|
55
|
+
# recursing down through open items.
|
|
17
56
|
def refresh
|
|
18
57
|
notify_listeners(:refresh)
|
|
19
58
|
end
|
|
59
|
+
|
|
60
|
+
# Begin an edit operation on the node. This allows the user
|
|
61
|
+
# to edit the text. When the user has finished, TreeController#edited
|
|
62
|
+
# will be called with the new text.
|
|
63
|
+
def edit(node, select_from=nil, select_to=nil)
|
|
64
|
+
notify_listeners(:edit_element, node, select_from, select_to)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Expand the node.
|
|
68
|
+
def expand(node)
|
|
69
|
+
notify_listeners(:expand_element, node)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Select the node.
|
|
73
|
+
def select(node)
|
|
74
|
+
notify_listeners(:select_element, node)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# @return [Array<NodeMirror>] the selected nodes
|
|
78
|
+
def selection
|
|
79
|
+
controller.selection
|
|
80
|
+
end
|
|
20
81
|
end
|
|
21
82
|
end
|
|
22
83
|
|
|
@@ -1,11 +1,60 @@
|
|
|
1
1
|
|
|
2
2
|
module Redcar
|
|
3
3
|
class Tree
|
|
4
|
-
#
|
|
5
|
-
#
|
|
4
|
+
# SPI specification. Implement a class including this module
|
|
5
|
+
# and pass an instance to Tree#new to respond to tree events.
|
|
6
6
|
module Controller
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
# Called when a node in a tree is activated (e.g double clicked).
|
|
9
|
+
# ONLY called when that node is a leaf node. If the node is not a
|
|
10
|
+
# leaf node then the tree will expand the node instead and query
|
|
11
|
+
# for its children.
|
|
12
|
+
def activated(tree, node); end
|
|
13
|
+
|
|
14
|
+
# Called when a node in a tree is right clicked on. node may be nil
|
|
15
|
+
# if the right click happened over the tree but not on a node.
|
|
16
|
+
def right_click(tree, node); end
|
|
17
|
+
|
|
18
|
+
# Called after an edit operation with the new text of the
|
|
19
|
+
# node. See Tree#edit
|
|
20
|
+
def edited(tree, node, text); end
|
|
21
|
+
|
|
22
|
+
# Called when a drag operation begins. Should return
|
|
23
|
+
# a Redcar::Tree::Controller::DragController.
|
|
24
|
+
def drag_controller(tree)
|
|
25
|
+
DragController::Fake.new
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# SPI for Tree drag and drop. Implement this class to support drag and
|
|
29
|
+
# drop in your tree.
|
|
30
|
+
module DragController
|
|
31
|
+
class Fake; include DragController; end
|
|
32
|
+
|
|
33
|
+
# Can elements in the tree be reordered by dragging and
|
|
34
|
+
# dropping? Shows insertion feedback in the GUI.
|
|
35
|
+
def reorderable?
|
|
36
|
+
false
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Called with the dragged nodes when a drag operation begins
|
|
40
|
+
def drag_start(nodes); end
|
|
41
|
+
|
|
42
|
+
# Called during a drag operation when the cursor hovers over other
|
|
43
|
+
# rows.
|
|
44
|
+
#
|
|
45
|
+
# @param nodes - the dragged nodes
|
|
46
|
+
# @param target - the hovered over node, or nil if the empty tree area
|
|
47
|
+
# @param position - one of :onto, :before, :after (always :onto unless
|
|
48
|
+
# reorderable?)
|
|
49
|
+
def can_drop?(nodes, target, position); end
|
|
50
|
+
|
|
51
|
+
# Called when the user has dropped nodes onto another node.
|
|
52
|
+
#
|
|
53
|
+
# @param nodes - the dragged nodes
|
|
54
|
+
# @param target - the hovered over node, or nil if the empty tree area
|
|
55
|
+
# @param position - one of :onto, :before, :after (always :onto unless
|
|
56
|
+
# reorderable?)
|
|
57
|
+
def do_drop(nodes, target, position); end
|
|
9
58
|
end
|
|
10
59
|
end
|
|
11
60
|
end
|