135
136
137
138
139
140
141
142
143
144
145
146
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
# File 'lib/cheri/jruby/explorer/dialogs.rb', line 135
def initialize(main)
swing[:auto=>true]
@main = main
@main_frame = main.main_frame
@dialog = dialog @main_frame, 'Search ObjectSpace', true do |d|
box_layout d, :Y_AXIS
size 400,300
default_close_operation :HIDE_ON_CLOSE
y_glue
x_panel do
x_spacer 4
label 'Instance:'
x_spacer 10
@instance_list = combo_box instance_list do
editable false
end
x_spacer 4
end
y_glue
x_panel do
compound_border(
titled_border('Find specific object') { etched_border :LOWERED },
empty_border(4,8,4,8)
)
y_box do
label 'Object id:'
end
x_spacer 10
y_box do
y_glue
@object_id = text_field do
columns 16
fixed_size 100,24
end
y_glue
end
x_glue
y_box do
y_glue
button 'Find' do
on_click do
id = nil_if_empty(@object_id.text)
id = Integer(id) rescue nil if id
if !id
JOptionPane.show_message_dialog(@dialog,"Please enter a valid id",
'Search Error', JOptionPane::ERROR_MESSAGE)
else
@dialog.visible = false
@object_id.text = ''
@main.new_find(@instances[@instance_list.selected_index],id)
end
end
end
y_glue
end
end
y_glue
y_panel do
compound_border(
titled_border('Search for instances by type and optional variable/value') { etched_border :LOWERED },
empty_border(4,8,4,8)
)
x_panel do
y_box do
y_glue
label 'Class or Module:'
y_glue
label 'Variable name:'
y_glue
label 'Search string or /regexp/:'
y_glue
end
x_spacer 6
y_box do
y_glue
label '@'
y_glue
end
y_box do
y_glue
@clazz = text_field do
columns 20
fixed_size 200,24
end
y_glue
@name1 = text_field do
columns 20
fixed_size 200,24
end
y_glue
@value1 = text_field do
columns 20
fixed_size 200,24
end
y_glue
end
x_glue
y_box do
button 'Find' do
on_click do
clazz = nil_if_empty(@clazz.text)
name = nil_if_empty(@name1.text)
value = @value1.text
value = nil if value.empty?
if !clazz
JOptionPane.show_message_dialog(@dialog,"Please enter a Class or Module name",
'Search Error', JOptionPane::ERROR_MESSAGE)
elsif clazz !~ /^([A-Z])((\w|::[A-Z])*)$/
JOptionPane.show_message_dialog(@dialog,"Invalid Class or Module name, please re-enter",
'Search Error', JOptionPane::ERROR_MESSAGE)
elsif name && name !~ /^([A-Za-z_])(\w*)$/
JOptionPane.show_message_dialog(@dialog,"Invalid variable name, please re-enter",
'Search Error', JOptionPane::ERROR_MESSAGE)
else
if value && value.strip.length != value.length
rsp = JOptionPane.show_confirm_dialog(@main_frame,
"Value contains leading/trailing whitespace -- continue?")
else
rsp = nil
end
unless rsp && rsp != JOptionPane::YES_OPTION
@dialog.visible = false
gc = @gc.selected
reset_fields
@main.new_search(@instances[@instance_list.selected_index],clazz,name,value,gc)
end
end
end
end
end
end
x_panel do
@gc = check_box 'GC target instance before search'
end
end
y_glue
x_box do
x_glue
button 'Cancel' do
on_click do
@dialog.visible = false
end
end
x_glue
end
y_glue
end
@main.center(@main_frame,@dialog)
end
|