sweetgui 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/examples/nodetree.rb +96 -0
  2. data/icons/Thumbs.db +0 -0
  3. data/icons/action_back.gif +0 -0
  4. data/icons/action_forward.gif +0 -0
  5. data/icons/action_go.gif +0 -0
  6. data/icons/action_paste.gif +0 -0
  7. data/icons/action_print.gif +0 -0
  8. data/icons/action_refresh.gif +0 -0
  9. data/icons/action_refresh_blue.gif +0 -0
  10. data/icons/action_save.gif +0 -0
  11. data/icons/action_stop.gif +0 -0
  12. data/icons/application_dreamweaver.gif +0 -0
  13. data/icons/application_firefox.gif +0 -0
  14. data/icons/application_flash.gif +0 -0
  15. data/icons/arrow_down.gif +0 -0
  16. data/icons/arrow_left.gif +0 -0
  17. data/icons/arrow_right.gif +0 -0
  18. data/icons/arrow_up.gif +0 -0
  19. data/icons/box.gif +0 -0
  20. data/icons/calendar.gif +0 -0
  21. data/icons/comment.gif +0 -0
  22. data/icons/comment_blue.gif +0 -0
  23. data/icons/comment_delete.gif +0 -0
  24. data/icons/comment_new.gif +0 -0
  25. data/icons/comment_yellow.gif +0 -0
  26. data/icons/copy.gif +0 -0
  27. data/icons/cut.gif +0 -0
  28. data/icons/date.gif +0 -0
  29. data/icons/date_delete.gif +0 -0
  30. data/icons/date_new.gif +0 -0
  31. data/icons/file_acrobat.gif +0 -0
  32. data/icons/file_font.gif +0 -0
  33. data/icons/file_font_truetype.gif +0 -0
  34. data/icons/flag_blue.gif +0 -0
  35. data/icons/flag_green.gif +0 -0
  36. data/icons/flag_orange.gif +0 -0
  37. data/icons/flag_red.gif +0 -0
  38. data/icons/flag_white.gif +0 -0
  39. data/icons/folder.gif +0 -0
  40. data/icons/folder_delete.gif +0 -0
  41. data/icons/folder_images.gif +0 -0
  42. data/icons/folder_lock.gif +0 -0
  43. data/icons/folder_new.gif +0 -0
  44. data/icons/folder_page.gif +0 -0
  45. data/icons/icon_accept.gif +0 -0
  46. data/icons/icon_airmail.gif +0 -0
  47. data/icons/icon_alert.gif +0 -0
  48. data/icons/icon_attachment.gif +0 -0
  49. data/icons/icon_clock.gif +0 -0
  50. data/icons/icon_component.gif +0 -0
  51. data/icons/icon_download.gif +0 -0
  52. data/icons/icon_email.gif +0 -0
  53. data/icons/icon_extension.gif +0 -0
  54. data/icons/icon_favourites.gif +0 -0
  55. data/icons/icon_get_world.gif +0 -0
  56. data/icons/icon_history.gif +0 -0
  57. data/icons/icon_home.gif +0 -0
  58. data/icons/icon_info.gif +0 -0
  59. data/icons/icon_key.gif +0 -0
  60. data/icons/icon_link.gif +0 -0
  61. data/icons/icon_mail.gif +0 -0
  62. data/icons/icon_monitor_mac.gif +0 -0
  63. data/icons/icon_monitor_pc.gif +0 -0
  64. data/icons/icon_network.gif +0 -0
  65. data/icons/icon_package.gif +0 -0
  66. data/icons/icon_package_get.gif +0 -0
  67. data/icons/icon_package_open.gif +0 -0
  68. data/icons/icon_padlock.gif +0 -0
  69. data/icons/icon_security.gif +0 -0
  70. data/icons/icon_settings.gif +0 -0
  71. data/icons/icon_user.gif +0 -0
  72. data/icons/icon_wand.gif +0 -0
  73. data/icons/icon_world.gif +0 -0
  74. data/icons/icon_world_dynamic.gif +0 -0
  75. data/icons/image.gif +0 -0
  76. data/icons/image_new.gif +0 -0
  77. data/icons/interface_browser.gif +0 -0
  78. data/icons/interface_dialog.gif +0 -0
  79. data/icons/interface_installer.gif +0 -0
  80. data/icons/list_comments.gif +0 -0
  81. data/icons/list_components.gif +0 -0
  82. data/icons/list_errors.gif +0 -0
  83. data/icons/list_extensions.gif +0 -0
  84. data/icons/list_images.gif +0 -0
  85. data/icons/list_keys.gif +0 -0
  86. data/icons/list_links.gif +0 -0
  87. data/icons/list_packages.gif +0 -0
  88. data/icons/list_security.gif +0 -0
  89. data/icons/list_settings.gif +0 -0
  90. data/icons/list_users.gif +0 -0
  91. data/icons/list_world.gif +0 -0
  92. data/icons/note.gif +0 -0
  93. data/icons/note_delete.gif +0 -0
  94. data/icons/note_new.gif +0 -0
  95. data/icons/page.gif +0 -0
  96. data/icons/page_alert.gif +0 -0
  97. data/icons/page_attachment.gif +0 -0
  98. data/icons/page_bookmark.gif +0 -0
  99. data/icons/page_boy.gif +0 -0
  100. data/icons/page_code.gif +0 -0
  101. data/icons/page_colors.gif +0 -0
  102. data/icons/page_component.gif +0 -0
  103. data/icons/page_cross.gif +0 -0
  104. data/icons/page_delete.gif +0 -0
  105. data/icons/page_deny.gif +0 -0
  106. data/icons/page_down.gif +0 -0
  107. data/icons/page_dynamic.gif +0 -0
  108. data/icons/page_edit.gif +0 -0
  109. data/icons/page_extension.gif +0 -0
  110. data/icons/page_favourites.gif +0 -0
  111. data/icons/page_find.gif +0 -0
  112. data/icons/page_flash.gif +0 -0
  113. data/icons/page_girl.gif +0 -0
  114. data/icons/page_html.gif +0 -0
  115. data/icons/page_java.gif +0 -0
  116. data/icons/page_key.gif +0 -0
  117. data/icons/page_left.gif +0 -0
  118. data/icons/page_link.gif +0 -0
  119. data/icons/page_lock.gif +0 -0
  120. data/icons/page_new.gif +0 -0
  121. data/icons/page_next.gif +0 -0
  122. data/icons/page_package.gif +0 -0
  123. data/icons/page_php.gif +0 -0
  124. data/icons/page_prev.gif +0 -0
  125. data/icons/page_refresh.gif +0 -0
  126. data/icons/page_right.gif +0 -0
  127. data/icons/page_script.gif +0 -0
  128. data/icons/page_security.gif +0 -0
  129. data/icons/page_settings.gif +0 -0
  130. data/icons/page_sound.gif +0 -0
  131. data/icons/page_tag_blue.gif +0 -0
  132. data/icons/page_tag_red.gif +0 -0
  133. data/icons/page_text.gif +0 -0
  134. data/icons/page_text_delete.gif +0 -0
  135. data/icons/page_tick.gif +0 -0
  136. data/icons/page_tree.gif +0 -0
  137. data/icons/page_up.gif +0 -0
  138. data/icons/page_url.gif +0 -0
  139. data/icons/page_user.gif +0 -0
  140. data/icons/page_user_dark.gif +0 -0
  141. data/icons/page_user_light.gif +0 -0
  142. data/icons/page_video.gif +0 -0
  143. data/icons/page_wizard.gif +0 -0
  144. data/icons/readme.txt +2 -0
  145. data/icons/table.gif +0 -0
  146. data/icons/table_delete.gif +0 -0
  147. data/icons/tables.gif +0 -0
  148. data/lib/apps/objecttree.rb +141 -0
  149. data/lib/swt.rb +464 -0
  150. data/lib/test2.class +0 -0
  151. data/tests/ts_swt.rb +54 -0
  152. 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
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/box.gif ADDED
Binary file
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
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
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
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/image.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
data/icons/note.gif ADDED
Binary file
Binary file
Binary file
data/icons/page.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
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
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/icons/page_up.gif ADDED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/icons/readme.txt ADDED
@@ -0,0 +1,2 @@
1
+ mini icons - famfamfam.com
2
+ Contact: mjames@gmail.com
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