sweetgui 0.0.3
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/examples/nodetree.rb +96 -0
- data/icons/Thumbs.db +0 -0
- data/icons/action_back.gif +0 -0
- data/icons/action_forward.gif +0 -0
- data/icons/action_go.gif +0 -0
- data/icons/action_paste.gif +0 -0
- data/icons/action_print.gif +0 -0
- data/icons/action_refresh.gif +0 -0
- data/icons/action_refresh_blue.gif +0 -0
- data/icons/action_save.gif +0 -0
- data/icons/action_stop.gif +0 -0
- data/icons/application_dreamweaver.gif +0 -0
- data/icons/application_firefox.gif +0 -0
- data/icons/application_flash.gif +0 -0
- data/icons/arrow_down.gif +0 -0
- data/icons/arrow_left.gif +0 -0
- data/icons/arrow_right.gif +0 -0
- data/icons/arrow_up.gif +0 -0
- data/icons/box.gif +0 -0
- data/icons/calendar.gif +0 -0
- data/icons/comment.gif +0 -0
- data/icons/comment_blue.gif +0 -0
- data/icons/comment_delete.gif +0 -0
- data/icons/comment_new.gif +0 -0
- data/icons/comment_yellow.gif +0 -0
- data/icons/copy.gif +0 -0
- data/icons/cut.gif +0 -0
- data/icons/date.gif +0 -0
- data/icons/date_delete.gif +0 -0
- data/icons/date_new.gif +0 -0
- data/icons/file_acrobat.gif +0 -0
- data/icons/file_font.gif +0 -0
- data/icons/file_font_truetype.gif +0 -0
- data/icons/flag_blue.gif +0 -0
- data/icons/flag_green.gif +0 -0
- data/icons/flag_orange.gif +0 -0
- data/icons/flag_red.gif +0 -0
- data/icons/flag_white.gif +0 -0
- data/icons/folder.gif +0 -0
- data/icons/folder_delete.gif +0 -0
- data/icons/folder_images.gif +0 -0
- data/icons/folder_lock.gif +0 -0
- data/icons/folder_new.gif +0 -0
- data/icons/folder_page.gif +0 -0
- data/icons/icon_accept.gif +0 -0
- data/icons/icon_airmail.gif +0 -0
- data/icons/icon_alert.gif +0 -0
- data/icons/icon_attachment.gif +0 -0
- data/icons/icon_clock.gif +0 -0
- data/icons/icon_component.gif +0 -0
- data/icons/icon_download.gif +0 -0
- data/icons/icon_email.gif +0 -0
- data/icons/icon_extension.gif +0 -0
- data/icons/icon_favourites.gif +0 -0
- data/icons/icon_get_world.gif +0 -0
- data/icons/icon_history.gif +0 -0
- data/icons/icon_home.gif +0 -0
- data/icons/icon_info.gif +0 -0
- data/icons/icon_key.gif +0 -0
- data/icons/icon_link.gif +0 -0
- data/icons/icon_mail.gif +0 -0
- data/icons/icon_monitor_mac.gif +0 -0
- data/icons/icon_monitor_pc.gif +0 -0
- data/icons/icon_network.gif +0 -0
- data/icons/icon_package.gif +0 -0
- data/icons/icon_package_get.gif +0 -0
- data/icons/icon_package_open.gif +0 -0
- data/icons/icon_padlock.gif +0 -0
- data/icons/icon_security.gif +0 -0
- data/icons/icon_settings.gif +0 -0
- data/icons/icon_user.gif +0 -0
- data/icons/icon_wand.gif +0 -0
- data/icons/icon_world.gif +0 -0
- data/icons/icon_world_dynamic.gif +0 -0
- data/icons/image.gif +0 -0
- data/icons/image_new.gif +0 -0
- data/icons/interface_browser.gif +0 -0
- data/icons/interface_dialog.gif +0 -0
- data/icons/interface_installer.gif +0 -0
- data/icons/list_comments.gif +0 -0
- data/icons/list_components.gif +0 -0
- data/icons/list_errors.gif +0 -0
- data/icons/list_extensions.gif +0 -0
- data/icons/list_images.gif +0 -0
- data/icons/list_keys.gif +0 -0
- data/icons/list_links.gif +0 -0
- data/icons/list_packages.gif +0 -0
- data/icons/list_security.gif +0 -0
- data/icons/list_settings.gif +0 -0
- data/icons/list_users.gif +0 -0
- data/icons/list_world.gif +0 -0
- data/icons/note.gif +0 -0
- data/icons/note_delete.gif +0 -0
- data/icons/note_new.gif +0 -0
- data/icons/page.gif +0 -0
- data/icons/page_alert.gif +0 -0
- data/icons/page_attachment.gif +0 -0
- data/icons/page_bookmark.gif +0 -0
- data/icons/page_boy.gif +0 -0
- data/icons/page_code.gif +0 -0
- data/icons/page_colors.gif +0 -0
- data/icons/page_component.gif +0 -0
- data/icons/page_cross.gif +0 -0
- data/icons/page_delete.gif +0 -0
- data/icons/page_deny.gif +0 -0
- data/icons/page_down.gif +0 -0
- data/icons/page_dynamic.gif +0 -0
- data/icons/page_edit.gif +0 -0
- data/icons/page_extension.gif +0 -0
- data/icons/page_favourites.gif +0 -0
- data/icons/page_find.gif +0 -0
- data/icons/page_flash.gif +0 -0
- data/icons/page_girl.gif +0 -0
- data/icons/page_html.gif +0 -0
- data/icons/page_java.gif +0 -0
- data/icons/page_key.gif +0 -0
- data/icons/page_left.gif +0 -0
- data/icons/page_link.gif +0 -0
- data/icons/page_lock.gif +0 -0
- data/icons/page_new.gif +0 -0
- data/icons/page_next.gif +0 -0
- data/icons/page_package.gif +0 -0
- data/icons/page_php.gif +0 -0
- data/icons/page_prev.gif +0 -0
- data/icons/page_refresh.gif +0 -0
- data/icons/page_right.gif +0 -0
- data/icons/page_script.gif +0 -0
- data/icons/page_security.gif +0 -0
- data/icons/page_settings.gif +0 -0
- data/icons/page_sound.gif +0 -0
- data/icons/page_tag_blue.gif +0 -0
- data/icons/page_tag_red.gif +0 -0
- data/icons/page_text.gif +0 -0
- data/icons/page_text_delete.gif +0 -0
- data/icons/page_tick.gif +0 -0
- data/icons/page_tree.gif +0 -0
- data/icons/page_up.gif +0 -0
- data/icons/page_url.gif +0 -0
- data/icons/page_user.gif +0 -0
- data/icons/page_user_dark.gif +0 -0
- data/icons/page_user_light.gif +0 -0
- data/icons/page_video.gif +0 -0
- data/icons/page_wizard.gif +0 -0
- data/icons/readme.txt +2 -0
- data/icons/table.gif +0 -0
- data/icons/table_delete.gif +0 -0
- data/icons/tables.gif +0 -0
- data/lib/apps/objecttree.rb +141 -0
- data/lib/swt.rb +464 -0
- data/lib/test2.class +0 -0
- data/tests/ts_swt.rb +54 -0
- metadata +196 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# The contents of this file are subject to the Mozilla Public License
|
|
2
|
+
# Version 1.1 (the "License"); you may not use this file except in
|
|
3
|
+
# compliance with the License. You may obtain a copy of the License at
|
|
4
|
+
# http://www.mozilla.org/MPL/
|
|
5
|
+
#
|
|
6
|
+
# Software distributed under the License is distributed on an "AS IS"
|
|
7
|
+
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
8
|
+
# License for the specific language governing rights and limitations
|
|
9
|
+
# under the License.
|
|
10
|
+
#
|
|
11
|
+
# The Initial Developer of the Original Code is Johannes Rudolph.
|
|
12
|
+
# Portions created by the Initial Developer are Copyright (C) 2006
|
|
13
|
+
# the Initial Developer. All Rights Reserved.
|
|
14
|
+
#
|
|
15
|
+
# Contributor(s):
|
|
16
|
+
# Johannes Rudolph <johannes_rudolph@gmail.com>
|
|
17
|
+
|
|
18
|
+
require 'java'
|
|
19
|
+
require 'rubygems'
|
|
20
|
+
require_gem 'sweetgui'
|
|
21
|
+
|
|
22
|
+
class Method
|
|
23
|
+
def name
|
|
24
|
+
method_field=Java::JavaClass.for_name('org.jruby.RubyMethod').declared_field('methodName')
|
|
25
|
+
method_field.accessible=true
|
|
26
|
+
Java::java_to_ruby(method_field.value(Java::ruby_to_java(self)))
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
module JRubyUtils
|
|
31
|
+
class NodeHelper
|
|
32
|
+
include_class 'org.jruby.internal.runtime.methods.DefaultMethod'
|
|
33
|
+
include_class 'org.jruby.internal.runtime.methods.EvaluateCallable'
|
|
34
|
+
def NodeHelper.get_method_field
|
|
35
|
+
return @method_field if @method_field
|
|
36
|
+
@method_field=Java::JavaClass.for_name('org.jruby.RubyMethod').declared_field('method')
|
|
37
|
+
@method_field.accessible=true
|
|
38
|
+
@method_field
|
|
39
|
+
end
|
|
40
|
+
def NodeHelper.get_nodes(method)
|
|
41
|
+
jmethod=Java.ruby_to_java method
|
|
42
|
+
callable=Java.java_to_ruby(get_method_field.value(jmethod))
|
|
43
|
+
return callable.getBody if callable.is_a? DefaultMethod
|
|
44
|
+
return callable.getNode if callable.is_a? EvaluateCallable
|
|
45
|
+
end
|
|
46
|
+
def NodeHelper.get_source_line(file,line)
|
|
47
|
+
@files={} unless @files
|
|
48
|
+
|
|
49
|
+
unless @files[file]
|
|
50
|
+
@files[file]=File.open file do |f|
|
|
51
|
+
f.readlines
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
lines=@files[file]
|
|
55
|
+
lines[line].strip
|
|
56
|
+
end
|
|
57
|
+
def NodeHelper.treeify(method)
|
|
58
|
+
nodes=get_nodes method
|
|
59
|
+
SWT::Builder.go do
|
|
60
|
+
shell method.name do
|
|
61
|
+
tree=tree (:verticalFill=>true,:horizontalFill=>true) do
|
|
62
|
+
column "Node"
|
|
63
|
+
column "File"
|
|
64
|
+
column "Line"
|
|
65
|
+
column "Code"
|
|
66
|
+
child method.name do
|
|
67
|
+
object {nodes}
|
|
68
|
+
child do
|
|
69
|
+
@node=container do
|
|
70
|
+
label {|x|x.getNodeNamePublic}
|
|
71
|
+
cell(1) {|x|x.getPosition.getFile}
|
|
72
|
+
cell(2) do |x|
|
|
73
|
+
pos=x.getPosition
|
|
74
|
+
"#{pos.getStartLine}-#{pos.getEndLine}"
|
|
75
|
+
end
|
|
76
|
+
cell(3) do |node|
|
|
77
|
+
pos=node.getPosition
|
|
78
|
+
NodeHelper.get_source_line(pos.getFile,pos.getStartLine)
|
|
79
|
+
end
|
|
80
|
+
children(lambda{|x|x.childNodes}) do
|
|
81
|
+
link {@node}
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def wurst
|
|
94
|
+
puts "Hello World!"
|
|
95
|
+
end
|
|
96
|
+
JRubyUtils::NodeHelper.treeify JRubyUtils::NodeHelper.method('wurst')
|
data/icons/Thumbs.db
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/action_go.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/arrow_up.gif
ADDED
|
Binary file
|
data/icons/box.gif
ADDED
|
Binary file
|
data/icons/calendar.gif
ADDED
|
Binary file
|
data/icons/comment.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/copy.gif
ADDED
|
Binary file
|
data/icons/cut.gif
ADDED
|
Binary file
|
data/icons/date.gif
ADDED
|
Binary file
|
|
Binary file
|
data/icons/date_new.gif
ADDED
|
Binary file
|
|
Binary file
|
data/icons/file_font.gif
ADDED
|
Binary file
|
|
Binary file
|
data/icons/flag_blue.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/flag_red.gif
ADDED
|
Binary file
|
|
Binary file
|
data/icons/folder.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/icon_home.gif
ADDED
|
Binary file
|
data/icons/icon_info.gif
ADDED
|
Binary file
|
data/icons/icon_key.gif
ADDED
|
Binary file
|
data/icons/icon_link.gif
ADDED
|
Binary file
|
data/icons/icon_mail.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/icon_user.gif
ADDED
|
Binary file
|
data/icons/icon_wand.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/image.gif
ADDED
|
Binary file
|
data/icons/image_new.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/list_keys.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/note.gif
ADDED
|
Binary file
|
|
Binary file
|
data/icons/note_new.gif
ADDED
|
Binary file
|
data/icons/page.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/page_boy.gif
ADDED
|
Binary file
|
data/icons/page_code.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/page_deny.gif
ADDED
|
Binary file
|
data/icons/page_down.gif
ADDED
|
Binary file
|
|
Binary file
|
data/icons/page_edit.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/page_find.gif
ADDED
|
Binary file
|
|
Binary file
|
data/icons/page_girl.gif
ADDED
|
Binary file
|
data/icons/page_html.gif
ADDED
|
Binary file
|
data/icons/page_java.gif
ADDED
|
Binary file
|
data/icons/page_key.gif
ADDED
|
Binary file
|
data/icons/page_left.gif
ADDED
|
Binary file
|
data/icons/page_link.gif
ADDED
|
Binary file
|
data/icons/page_lock.gif
ADDED
|
Binary file
|
data/icons/page_new.gif
ADDED
|
Binary file
|
data/icons/page_next.gif
ADDED
|
Binary file
|
|
Binary file
|
data/icons/page_php.gif
ADDED
|
Binary file
|
data/icons/page_prev.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/page_text.gif
ADDED
|
Binary file
|
|
Binary file
|
data/icons/page_tick.gif
ADDED
|
Binary file
|
data/icons/page_tree.gif
ADDED
|
Binary file
|
data/icons/page_up.gif
ADDED
|
Binary file
|
data/icons/page_url.gif
ADDED
|
Binary file
|
data/icons/page_user.gif
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/icons/readme.txt
ADDED
data/icons/table.gif
ADDED
|
Binary file
|
|
Binary file
|
data/icons/tables.gif
ADDED
|
Binary file
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# The contents of this file are subject to the Mozilla Public License
|
|
2
|
+
# Version 1.1 (the "License"); you may not use this file except in
|
|
3
|
+
# compliance with the License. You may obtain a copy of the License at
|
|
4
|
+
# http://www.mozilla.org/MPL/
|
|
5
|
+
#
|
|
6
|
+
# Software distributed under the License is distributed on an "AS IS"
|
|
7
|
+
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
8
|
+
# License for the specific language governing rights and limitations
|
|
9
|
+
# under the License.
|
|
10
|
+
#
|
|
11
|
+
# The Initial Developer of the Original Code is Johannes Rudolph.
|
|
12
|
+
# Portions created by the Initial Developer are Copyright (C) 2006
|
|
13
|
+
# the Initial Developer. All Rights Reserved.
|
|
14
|
+
#
|
|
15
|
+
# Contributor(s):
|
|
16
|
+
# Johannes Rudolph <johannes_rudolph@gmail.com>
|
|
17
|
+
|
|
18
|
+
#require '../swt'
|
|
19
|
+
|
|
20
|
+
class Method
|
|
21
|
+
def name
|
|
22
|
+
method_field=Java::JavaClass.for_name('org.jruby.RubyMethod').declared_field('methodName')
|
|
23
|
+
method_field.accessible=true
|
|
24
|
+
Java::java_to_ruby(method_field.value(Java::ruby_to_java(self)))
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class ::SWT::TreeBuilder
|
|
29
|
+
include_class 'org.eclipse.swt.graphics.Image'
|
|
30
|
+
include_class 'org.eclipse.swt.widgets.Display'
|
|
31
|
+
def i(o)
|
|
32
|
+
@@image_cache={} unless defined? @@image_cache
|
|
33
|
+
return @@image_cache[o] if @@image_cache.has_key? o
|
|
34
|
+
res=File.expand_path(File.dirname(__FILE__)+"/../../"+o)
|
|
35
|
+
Image.new Display.getCurrent,res
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
module JRubyUtils
|
|
40
|
+
class RubyObjectBrowser
|
|
41
|
+
class << self
|
|
42
|
+
def object_tree(object)
|
|
43
|
+
SWT::Builder.go do
|
|
44
|
+
shell "JRuby Object Viewer by JR - visit http://virtual-void.net" do
|
|
45
|
+
tree(:verticalFill=>true,:horizontalFill=>true) do
|
|
46
|
+
child do
|
|
47
|
+
object {object}
|
|
48
|
+
@object=container do
|
|
49
|
+
label {|o|o.inspect}
|
|
50
|
+
image {i("icons/arrow_right.gif")}
|
|
51
|
+
|
|
52
|
+
# instance variables node
|
|
53
|
+
child "instance_variables" do
|
|
54
|
+
image {i("icons/flag_blue.gif")}
|
|
55
|
+
children(lambda{|o|o.instance_variables.sort.collect! {|x|{:object=>o,:name=>x} }}) do
|
|
56
|
+
image {i("icons/flag_blue.gif")}
|
|
57
|
+
label {|v|v[:name]}
|
|
58
|
+
child do
|
|
59
|
+
object {|ar|
|
|
60
|
+
#puts "Object: #{ar}"
|
|
61
|
+
#name.last.instance_variable_get name
|
|
62
|
+
ar[:object].instance_variable_get ar[:name]
|
|
63
|
+
}
|
|
64
|
+
label {|o|o.to_s}
|
|
65
|
+
link {@object}
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# methods node
|
|
71
|
+
child "methods" do
|
|
72
|
+
image {i("icons/page_text.gif")}
|
|
73
|
+
children(lambda {|o|
|
|
74
|
+
o.methods.sort.collect! do |name|
|
|
75
|
+
{:method=>name,:object=>o}
|
|
76
|
+
end
|
|
77
|
+
}) do
|
|
78
|
+
image {i("icons/page_text.gif")}
|
|
79
|
+
label {|h|h[:method]}
|
|
80
|
+
|
|
81
|
+
# execute method if it has no arguments
|
|
82
|
+
conditional lambda{|h|
|
|
83
|
+
(-1..0).include? h[:object].method(h[:method]).arity
|
|
84
|
+
} do
|
|
85
|
+
child do
|
|
86
|
+
object do |h|
|
|
87
|
+
begin
|
|
88
|
+
o=h[:object].dup
|
|
89
|
+
o.send(h[:method])
|
|
90
|
+
rescue Exception=>exc
|
|
91
|
+
exc
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
link {@object}
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# class node
|
|
101
|
+
child "class" do
|
|
102
|
+
object {|o|o.class}
|
|
103
|
+
@class=container do
|
|
104
|
+
image {i("icons/icon_component.gif")}
|
|
105
|
+
|
|
106
|
+
child do
|
|
107
|
+
image {i("icons/icon_component.gif")}
|
|
108
|
+
label{|c|c.to_s}
|
|
109
|
+
child "class_variables" do
|
|
110
|
+
image{i("icons/flag_red.gif")}
|
|
111
|
+
children(lambda{|c|c.class_variables.sort.collect! { |x|{:class=>c,:name=>x}}}) do
|
|
112
|
+
image{i("icons/flag_red.gif")}
|
|
113
|
+
label{|horizontalFill|h[:name]}
|
|
114
|
+
child do
|
|
115
|
+
image{i("icons/arrow_right.gif")}
|
|
116
|
+
label{|horizontalFill|h[:class].class_eval h[:name]}
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
link{@object}
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# superclass node if appropriate
|
|
124
|
+
conditional lambda{|c|c.superclass}do
|
|
125
|
+
child "superclass" do
|
|
126
|
+
image {i("icons/icon_component.gif")}
|
|
127
|
+
object{|c|c.superclass}
|
|
128
|
+
link{@class}
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|