cheri 0.0.9 → 0.5.0
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/grid_bag_layout_demo.rb +23 -0
- data/examples/grid_table_align.rb +34 -0
- data/examples/grid_table_columns.rb +24 -0
- data/lib/cheri.jar +0 -0
- data/lib/cheri/builder/context.rb +9 -8
- data/lib/cheri/builder/main.rb +5 -3
- data/lib/cheri/builder/swing/connecter.rb +30 -5
- data/lib/cheri/builder/swing/main-old.rb +467 -0
- data/lib/cheri/builder/swing/main.rb +21 -6
- data/lib/cheri/cheri.rb +3 -14
- data/lib/cheri/explorer/explorer.rb +3 -1
- data/lib/cheri/java/builder/main.rb +4 -1
- data/lib/cheri/java/java.rb +11 -11
- data/lib/cheri/jruby.rb +2 -1
- data/lib/cheri/jruby/explorer/dialogs-old.rb +407 -0
- data/lib/cheri/jruby/explorer/dialogs.rb +119 -210
- data/lib/cheri/jruby/explorer/explorer.rb +34 -30
- data/lib/cheri/jruby/explorer/viewer.rb +115 -202
- data/lib/cheri/jruby/explorer/viewers.rb +214 -304
- data/lib/cheri/jruby/jruby.rb +17 -2
- metadata +7 -2
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (C) 2007,2008 William N Dortch <bill.dortch@gmail.com>
|
2
|
+
# Copyright (C) 2007,2008,2009 William N Dortch <bill.dortch@gmail.com>
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -33,77 +33,28 @@ class ConnectionDialog
|
|
33
33
|
swing[:auto=>true]
|
34
34
|
@main = main
|
35
35
|
@main_frame = main.main_frame
|
36
|
-
@dialog = dialog @main_frame, 'New Connection', true do |
|
37
|
-
|
36
|
+
@dialog = dialog @main_frame, 'New Connection', true do |dlg|
|
37
|
+
grid_table_layout dlg
|
38
|
+
empty_border 4,4,4,4
|
38
39
|
size 240,180
|
39
40
|
default_close_operation :HIDE_ON_CLOSE
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
label 'Host:'
|
45
|
-
|
46
|
-
label '
|
47
|
-
y_spacer 4
|
48
|
-
label 'Display name:'
|
41
|
+
grid_row do
|
42
|
+
grid_table :i=>[0,8] do
|
43
|
+
compound_border etched_border(:LOWERED), empty_border(7,7,7,7)
|
44
|
+
defaults :i=>[4,1], :a=>:w
|
45
|
+
grid_row {label 'Host:'; @con_host = text_field('localhost') {columns 10}}
|
46
|
+
grid_row {label 'Port:'; @con_port = text_field {columns 10}}
|
47
|
+
grid_row {label 'Display name:'; @con_name = text_field {columns 10}}
|
49
48
|
end
|
50
|
-
x_spacer 10
|
51
|
-
y_box do
|
52
|
-
@con_host = text_field do
|
53
|
-
columns 10
|
54
|
-
maximum_size dimension(100,24)
|
55
|
-
text 'localhost'
|
56
|
-
end
|
57
|
-
y_spacer 4
|
58
|
-
@con_port = text_field do
|
59
|
-
columns 10
|
60
|
-
maximum_size dimension(100,24)
|
61
|
-
end
|
62
|
-
y_spacer 4
|
63
|
-
@con_name = text_field do
|
64
|
-
#align :RIGHT
|
65
|
-
columns 10
|
66
|
-
maximum_size dimension(100,24)
|
67
|
-
end
|
68
|
-
end
|
69
49
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
host = @con_host.text
|
76
|
-
host.strip! if host
|
77
|
-
port = @con_port.text
|
78
|
-
port.strip! if port
|
79
|
-
name = @con_name.text
|
80
|
-
if name
|
81
|
-
name.strip!
|
82
|
-
name = nil if name.empty?
|
83
|
-
end
|
84
|
-
if !port || port.empty?
|
85
|
-
JOptionPane.show_message_dialog(@main_frame,"Please enter a port number",
|
86
|
-
'Connection Error', JOptionPane::ERROR_MESSAGE)
|
87
|
-
elsif !(port = Integer(port) rescue nil)
|
88
|
-
JOptionPane.show_message_dialog(@main_frame,"Invalid port: #{@con_port.text}",
|
89
|
-
'Connection Error', JOptionPane::ERROR_MESSAGE)
|
90
|
-
else
|
91
|
-
@dialog.visible = false
|
92
|
-
reset_fields
|
93
|
-
@main.new_connection(port,name,host)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
x_spacer 10
|
98
|
-
button 'Cancel' do
|
99
|
-
on_click do
|
100
|
-
@dialog.visible = false
|
101
|
-
reset_fields
|
50
|
+
grid_row do
|
51
|
+
grid_table :wy=>0.1, :a=>:s do
|
52
|
+
grid_row :i=>4 do
|
53
|
+
button('Connect') {on_click{do_connect}}
|
54
|
+
button('Cancel') {on_click{@dialog.visible = false; reset_fields}}
|
102
55
|
end
|
103
56
|
end
|
104
|
-
x_glue
|
105
57
|
end
|
106
|
-
y_glue
|
107
58
|
end
|
108
59
|
reset_fields
|
109
60
|
@main.center(@main_frame,@dialog)
|
@@ -116,6 +67,25 @@ class ConnectionDialog
|
|
116
67
|
end
|
117
68
|
private :reset_fields
|
118
69
|
|
70
|
+
def do_connect
|
71
|
+
host = @con_host.text.strip
|
72
|
+
port = @con_port.text.strip
|
73
|
+
name = @con_name.text.strip
|
74
|
+
name = nil if name.empty?
|
75
|
+
if port.empty?
|
76
|
+
JOptionPane.show_message_dialog(@main_frame,"Please enter a port number",
|
77
|
+
'Connection Error', JOptionPane::ERROR_MESSAGE)
|
78
|
+
elsif !(port = Integer(port) rescue nil)
|
79
|
+
JOptionPane.show_message_dialog(@main_frame,"Invalid port: #{@con_port.text}",
|
80
|
+
'Connection Error', JOptionPane::ERROR_MESSAGE)
|
81
|
+
else
|
82
|
+
@dialog.visible = false
|
83
|
+
reset_fields
|
84
|
+
@main.new_connection(port,name,host)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
private :do_connect
|
88
|
+
|
119
89
|
def value
|
120
90
|
@dialog
|
121
91
|
end
|
@@ -136,153 +106,88 @@ class SearchDialog
|
|
136
106
|
swing[:auto=>true]
|
137
107
|
@main = main
|
138
108
|
@main_frame = main.main_frame
|
139
|
-
@dialog = dialog @main_frame, 'Search ObjectSpace', true do |
|
140
|
-
|
141
|
-
|
109
|
+
@dialog = dialog @main_frame, 'Search ObjectSpace', true do |dlg|
|
110
|
+
grid_table_layout dlg, :a=>:nw, :wx=>0.1, :wy=>0.1, :f=>:h
|
111
|
+
empty_border 4,4,4,4
|
112
|
+
size 400,350
|
142
113
|
default_close_operation :HIDE_ON_CLOSE
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
label 'Instance:'
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
button 'Find' do
|
175
|
-
on_click do
|
176
|
-
id = nil_if_empty(@object_id.text)
|
177
|
-
id = Integer(id) rescue nil if id
|
178
|
-
if !id
|
179
|
-
JOptionPane.show_message_dialog(@dialog,"Please enter a valid id",
|
180
|
-
'Search Error', JOptionPane::ERROR_MESSAGE)
|
181
|
-
else
|
182
|
-
@dialog.visible = false
|
183
|
-
@object_id.text = ''
|
184
|
-
@main.new_find(@instances[@instance_list.selected_index],id)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
y_glue
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
y_glue
|
114
|
+
grid_row{grid_table{
|
115
|
+
defaults :a=>:w, :i=>[4,2]
|
116
|
+
compound_border titled_border('Select instance') {etched_border :LOWERED}, empty_border(2,2,2,2)
|
117
|
+
grid_row {label 'Instance:'; @instance_list = combo_box(instance_list,:f=>:h,:wx=>0.1) {editable false}}
|
118
|
+
}}
|
119
|
+
grid_row{grid_table{
|
120
|
+
defaults :a=>:w,:i=>[4,2]
|
121
|
+
compound_border titled_border('Find specific object') {etched_border :LOWERED}, empty_border(2,2,2,2)
|
122
|
+
grid_row {
|
123
|
+
label 'Object id:'
|
124
|
+
@object_id = text_field(:wx=>0.1) {columns 16}
|
125
|
+
button('Find') {on_click {find_by_id}}
|
126
|
+
}
|
127
|
+
}}
|
128
|
+
grid_row{grid_table{
|
129
|
+
defaults :a=>:w,:i=>[4,2]
|
130
|
+
compound_border titled_border('Search for instances by type and optional variable/value') {etched_border :LOWERED},
|
131
|
+
empty_border(2,2,2,2)
|
132
|
+
grid_row {
|
133
|
+
label 'Class or Module:', :w=>2
|
134
|
+
@clazz = text_field(:wx=>0.1,:f=>:h) {columns 16}
|
135
|
+
button('Find', :h=>3,:a=>:c) {on_click {find_by_type}}
|
136
|
+
}
|
137
|
+
grid_row {label 'Variable name:'; label '@',:i=>0,:a=>:e; @name1 = text_field(:wx=>0.1,:f=>:h) {columns 16}}
|
138
|
+
grid_row {label 'Search string or /regexp/:',:w=>2; @value1 = text_field(:wx=>0.1,:f=>:h) {columns 16}}
|
139
|
+
grid_row {@gc = check_box 'GC target instance before search', :a=>:c, :w=>4}
|
140
|
+
}}
|
141
|
+
grid_row {button('Cancel', :a=>:c, :wx=>0.1, :f=>:none) {on_click {@dialog.visible = false; reset_fields}}}
|
142
|
+
end
|
143
|
+
@main.center(@main_frame,@dialog)
|
144
|
+
end
|
193
145
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
clazz = nil_if_empty(@clazz.text)
|
238
|
-
name = nil_if_empty(@name1.text)
|
239
|
-
value = @value1.text
|
240
|
-
value = nil if value.empty?
|
241
|
-
if !clazz
|
242
|
-
JOptionPane.show_message_dialog(@dialog,"Please enter a Class or Module name",
|
243
|
-
'Search Error', JOptionPane::ERROR_MESSAGE)
|
244
|
-
elsif clazz !~ /^([A-Z])((\w|::[A-Z])*)$/
|
245
|
-
JOptionPane.show_message_dialog(@dialog,"Invalid Class or Module name, please re-enter",
|
246
|
-
'Search Error', JOptionPane::ERROR_MESSAGE)
|
247
|
-
elsif name && name !~ /^([A-Za-z_])(\w*)$/
|
248
|
-
JOptionPane.show_message_dialog(@dialog,"Invalid variable name, please re-enter",
|
249
|
-
'Search Error', JOptionPane::ERROR_MESSAGE)
|
250
|
-
else
|
251
|
-
if value && value.strip.length != value.length
|
252
|
-
rsp = JOptionPane.show_confirm_dialog(@main_frame,
|
253
|
-
"Value contains leading/trailing whitespace -- continue?")
|
254
|
-
else
|
255
|
-
rsp = nil
|
256
|
-
end
|
257
|
-
unless rsp && rsp != JOptionPane::YES_OPTION
|
258
|
-
@dialog.visible = false
|
259
|
-
gc = @gc.selected
|
260
|
-
reset_fields
|
261
|
-
@main.new_search(@instances[@instance_list.selected_index],clazz,name,value,gc)
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
end
|
268
|
-
x_panel do
|
269
|
-
@gc = check_box 'GC target instance before search'
|
270
|
-
end
|
146
|
+
def find_by_id
|
147
|
+
id = nil_if_empty(@object_id.text)
|
148
|
+
id = Integer(id) rescue nil if id
|
149
|
+
if !id
|
150
|
+
JOptionPane.show_message_dialog(@dialog,"Please enter a valid id",
|
151
|
+
'Search Error', JOptionPane::ERROR_MESSAGE)
|
152
|
+
else
|
153
|
+
@dialog.visible = false
|
154
|
+
@object_id.text = ''
|
155
|
+
@main.new_find(@instances[@instance_list.selected_index],id)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def find_by_type
|
160
|
+
clazz = nil_if_empty(@clazz.text)
|
161
|
+
name = nil_if_empty(@name1.text)
|
162
|
+
value = @value1.text
|
163
|
+
value = nil if value.empty?
|
164
|
+
instance = @instances[@instance_list.selected_index]
|
165
|
+
if !clazz
|
166
|
+
JOptionPane.show_message_dialog(@dialog,"Please enter a Class or Module name",
|
167
|
+
'Search Error', JOptionPane::ERROR_MESSAGE)
|
168
|
+
elsif clazz !~ /^([A-Z])((\w|::[A-Z])*)$/
|
169
|
+
JOptionPane.show_message_dialog(@dialog,"Invalid Class or Module name, please re-enter",
|
170
|
+
'Search Error', JOptionPane::ERROR_MESSAGE)
|
171
|
+
elsif name && name !~ /^([A-Za-z_])(\w*)$/
|
172
|
+
JOptionPane.show_message_dialog(@dialog,"Invalid variable name, please re-enter",
|
173
|
+
'Search Error', JOptionPane::ERROR_MESSAGE)
|
174
|
+
elsif !instance.proxy.object_space? && clazz != 'Class'
|
175
|
+
JOptionPane.show_message_dialog(@dialog,"Only class 'Class' supported when ObjectSpace disabled",
|
176
|
+
'Search Error', JOptionPane::ERROR_MESSAGE)
|
177
|
+
else
|
178
|
+
if value && value.strip.length != value.length
|
179
|
+
rsp = JOptionPane.show_confirm_dialog(@main_frame,
|
180
|
+
"Value contains leading/trailing whitespace -- continue?")
|
181
|
+
else
|
182
|
+
rsp = nil
|
183
|
+
end
|
184
|
+
unless rsp && rsp != JOptionPane::YES_OPTION
|
185
|
+
@dialog.visible = false
|
186
|
+
gc = @gc.selected
|
187
|
+
reset_fields
|
188
|
+
@main.new_search(instance,clazz,name,value,gc)
|
271
189
|
end
|
272
|
-
y_glue
|
273
|
-
x_box do
|
274
|
-
x_glue
|
275
|
-
button 'Cancel' do
|
276
|
-
on_click do
|
277
|
-
@dialog.visible = false
|
278
|
-
end
|
279
|
-
end
|
280
|
-
x_glue
|
281
|
-
end
|
282
|
-
y_glue
|
283
190
|
end
|
284
|
-
|
285
|
-
@main.center(@main_frame,@dialog)
|
286
191
|
end
|
287
192
|
|
288
193
|
def nil_if_empty(val)
|
@@ -317,7 +222,11 @@ class SearchDialog
|
|
317
222
|
|
318
223
|
def instance_list
|
319
224
|
@instances = @main.instance_list
|
320
|
-
arr = Array.new(@instances.length) {|i|
|
225
|
+
arr = Array.new(@instances.length) {|i|
|
226
|
+
instance = @instances[i]
|
227
|
+
pfx = instance.proxy.object_space? ? 'en' : 'dis'
|
228
|
+
"#{instance.name} [#{pfx}abled]"
|
229
|
+
}
|
321
230
|
arr.to_java
|
322
231
|
end
|
323
232
|
|
@@ -356,7 +265,7 @@ class AboutDialog
|
|
356
265
|
body(:bgolor=>:white) { div(:align=>:center) {
|
357
266
|
h3 font(:color=>:blue) {"Cheri::JRuby::Explorer version #{Cheri::VERSION::STRING}"}
|
358
267
|
p 'Written by Bill Dortch ', esc('<cheri.project@gmail.com>'), br,
|
359
|
-
'Copyright © 2007 William N Dortch'
|
268
|
+
'Copyright © 2007-2009 William N Dortch'
|
360
269
|
p
|
361
270
|
table(:width=>'97%') {
|
362
271
|
tr{td(:align=>:left) {
|
@@ -61,12 +61,14 @@ end
|
|
61
61
|
|
62
62
|
class Main
|
63
63
|
include Cheri::Swing
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
|
65
|
+
import java.lang.Math
|
66
|
+
import java.lang.System
|
67
|
+
import java.lang.Thread
|
68
|
+
import java.util.WeakHashMap
|
69
|
+
import javax.swing.JComponent
|
70
|
+
import javax.swing.JOptionPane
|
71
|
+
|
70
72
|
FindIcon = CJava.get_icon('Find24.gif')
|
71
73
|
FindAgainIcon = CJava.get_icon('FindAgain24.gif')
|
72
74
|
SearchIcon = CJava.get_icon('Search24.gif')
|
@@ -82,6 +84,7 @@ class Main
|
|
82
84
|
jver = ENV_JAVA['java.version']
|
83
85
|
Java5 = String === jver && jver >= '1.5'
|
84
86
|
Java6 = String === jver && jver >= '1.6'
|
87
|
+
MAIN_TITLE = "Cheri::JRuby::Explorer v#{Cheri::VERSION::STRING} (JRuby v#{JRUBY_VERSION})"
|
85
88
|
|
86
89
|
# Maps viewer types into tab slots. Uncategorized viewers
|
87
90
|
# will be opened in tabs slots based on their primary type.
|
@@ -141,7 +144,8 @@ class Main
|
|
141
144
|
end
|
142
145
|
|
143
146
|
def main_frame(&block)
|
144
|
-
|
147
|
+
|
148
|
+
@main_frame ||= frame MAIN_TITLE do |frame|
|
145
149
|
size 800,600
|
146
150
|
box_layout frame, :Y_AXIS
|
147
151
|
#content_pane do box_layout frame, :Y_AXIS; end
|
@@ -807,29 +811,29 @@ class Main
|
|
807
811
|
end
|
808
812
|
end
|
809
813
|
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
814
|
+
def new_find(instance,id,new_tab=nil)
|
815
|
+
if rec = instance.proxy.object(id)
|
816
|
+
ntv = case rec.clazz
|
817
|
+
when 'Class' : NodeTypeValue.new(Class,rec.value,rec)
|
818
|
+
when 'Module' : NodeTypeValue.new(Module,rec.value,rec)
|
819
|
+
else NodeTypeValue.new(:object,rec.clazz,rec)
|
820
|
+
end
|
821
|
+
if (clazz = viewer(ntv.type,ntv.subtype))
|
822
|
+
vwr = clazz.new(ntv,self,instance,ntv.value)
|
823
|
+
view = vwr.view
|
824
|
+
set_view_viewer(view,vwr)
|
825
|
+
tabs = main_tab_pane
|
826
|
+
add_view_tab(tabs,view,vwr)
|
827
|
+
@main_tabs[instance.__id__][vwr.__id__] = vwr
|
828
|
+
tabs.set_selected_component(view)
|
829
|
+
else
|
830
|
+
JOptionPane.show_message_dialog(@main_frame,"Unable to display object #{id} (no viewer)")
|
831
|
+
end
|
832
|
+
else
|
833
|
+
JOptionPane.show_message_dialog(@main_frame,"Unable to retrieve object #{id} (garbage-collected?)")
|
834
|
+
end
|
835
|
+
end
|
836
|
+
|
833
837
|
def show_linked_object(curvwr,id,new_tab=nil)
|
834
838
|
instance = curvwr.instance
|
835
839
|
unless rec = instance.proxy.object(id)
|