cheri 0.0.2

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.
Files changed (79) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README +98 -0
  3. data/Rakefile +121 -0
  4. data/examples/hello_world_1.rb +28 -0
  5. data/examples/table_1.rb +44 -0
  6. data/lib/cheri/awt.rb +41 -0
  7. data/lib/cheri/builder.rb +31 -0
  8. data/lib/cheri/builder/awt/connecter.rb +63 -0
  9. data/lib/cheri/builder/awt/constants.rb +1003 -0
  10. data/lib/cheri/builder/awt/main.rb +191 -0
  11. data/lib/cheri/builder/awt/types.rb +220 -0
  12. data/lib/cheri/builder/base.rb +533 -0
  13. data/lib/cheri/builder/config.rb +187 -0
  14. data/lib/cheri/builder/connecter.rb +386 -0
  15. data/lib/cheri/builder/context.rb +655 -0
  16. data/lib/cheri/builder/generator.rb +425 -0
  17. data/lib/cheri/builder/html/charsets.rb +154 -0
  18. data/lib/cheri/builder/html/common.rb +32 -0
  19. data/lib/cheri/builder/html/connecter.rb +57 -0
  20. data/lib/cheri/builder/html/element.rb +156 -0
  21. data/lib/cheri/builder/html/main.rb +116 -0
  22. data/lib/cheri/builder/html/types.rb +123 -0
  23. data/lib/cheri/builder/main.rb +483 -0
  24. data/lib/cheri/builder/swing/connecter.rb +141 -0
  25. data/lib/cheri/builder/swing/constants.rb +420 -0
  26. data/lib/cheri/builder/swing/main.rb +446 -0
  27. data/lib/cheri/builder/swing/types.rb +270 -0
  28. data/lib/cheri/builder/xml/charsets.rb +154 -0
  29. data/lib/cheri/builder/xml/common.rb +32 -0
  30. data/lib/cheri/builder/xml/connecter.rb +42 -0
  31. data/lib/cheri/builder/xml/element.rb +189 -0
  32. data/lib/cheri/builder/xml/main.rb +130 -0
  33. data/lib/cheri/builder/xml/types.rb +36 -0
  34. data/lib/cheri/cheri.rb +70 -0
  35. data/lib/cheri/cjx.rb +3 -0
  36. data/lib/cheri/explorer.rb +32 -0
  37. data/lib/cheri/explorer/explorer.rb +560 -0
  38. data/lib/cheri/html.rb +31 -0
  39. data/lib/cheri/image/Delete24.gif +0 -0
  40. data/lib/cheri/image/Find24.gif +0 -0
  41. data/lib/cheri/image/FindAgain24.gif +0 -0
  42. data/lib/cheri/image/Refresh24.gif +0 -0
  43. data/lib/cheri/image/Search24.gif +0 -0
  44. data/lib/cheri/image/Thumbs.db +0 -0
  45. data/lib/cheri/image/cheri_icon_16x16.png +0 -0
  46. data/lib/cheri/image/cheri_icon_24x24.png +0 -0
  47. data/lib/cheri/image/cheri_logo_medium.png +0 -0
  48. data/lib/cheri/image/close_10x10.png +0 -0
  49. data/lib/cheri/image/close_10x10s.png +0 -0
  50. data/lib/cheri/image/close_12x12.png +0 -0
  51. data/lib/cheri/image/close_14x14.png +0 -0
  52. data/lib/cheri/image/close_24x24.png +0 -0
  53. data/lib/cheri/image/close_dim2_12x12.png +0 -0
  54. data/lib/cheri/image/close_dim_12x12.png +0 -0
  55. data/lib/cheri/image/cls_tree.png +0 -0
  56. data/lib/cheri/image/con_tree.png +0 -0
  57. data/lib/cheri/image/jruby_14x16.png +0 -0
  58. data/lib/cheri/image/jruby_logo.png +0 -0
  59. data/lib/cheri/image/mod_tree.png +0 -0
  60. data/lib/cheri/image/obj_tree.png +0 -0
  61. data/lib/cheri/image/ruby_16x16.png +0 -0
  62. data/lib/cheri/image/vars_tree.png +0 -0
  63. data/lib/cheri/java.rb +26 -0
  64. data/lib/cheri/java/builder.rb +28 -0
  65. data/lib/cheri/java/builder/main.rb +407 -0
  66. data/lib/cheri/java/builder/util.rb +480 -0
  67. data/lib/cheri/java/java.rb +56 -0
  68. data/lib/cheri/jruby.rb +32 -0
  69. data/lib/cheri/jruby/explorer.rb +43 -0
  70. data/lib/cheri/jruby/explorer/common.rb +38 -0
  71. data/lib/cheri/jruby/explorer/dialogs.rb +383 -0
  72. data/lib/cheri/jruby/explorer/explorer.rb +904 -0
  73. data/lib/cheri/jruby/explorer/splash.rb +80 -0
  74. data/lib/cheri/jruby/explorer/viewer.rb +619 -0
  75. data/lib/cheri/jruby/explorer/viewers.rb +1057 -0
  76. data/lib/cheri/jruby/jruby.rb +59 -0
  77. data/lib/cheri/swing.rb +41 -0
  78. data/lib/cheri/xml.rb +31 -0
  79. metadata +135 -0
@@ -0,0 +1,80 @@
1
+ #--
2
+ # Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ #
24
+
25
+
26
+ module Cheri
27
+ module JRuby
28
+ module Explorer
29
+ class SplashScreen
30
+ include Cheri::Swing
31
+ Font = ::Java::JavaAwt::Font
32
+ def initialize
33
+ swing[:auto => true]
34
+ end
35
+ def splash(&block)
36
+ img_path = Cheri.img_path
37
+ @panel ||= y_panel do
38
+ align :LEFT
39
+ background :WHITE; bevel_border :LOWERED
40
+ y_spacer 56
41
+ x_box do
42
+ x_glue
43
+ x_spacer 20
44
+ y_box do
45
+ label image_icon("#{img_path}cheri_logo_medium.png")
46
+ y_spacer 100
47
+ end
48
+ y_box do
49
+ y_spacer 100
50
+ label image_icon("#{img_path}jruby_logo.png")
51
+ end
52
+ x_spacer 50
53
+ x_glue
54
+ end
55
+ x_box do
56
+ label 'E x p l o r e r' do
57
+ font 'Dialog', Font::BOLD|Font::ITALIC, 100; align :CENTER; foreground :BLUE
58
+ end
59
+ x_spacer 50
60
+ end
61
+ y_glue
62
+ x_box do
63
+ label '(C) 2007 Bill Dortch. JRuby logo (C) 2006 Codehaus Foundation.' do
64
+ foreground :GRAY; font 'Dialog',:BOLD,11
65
+ end
66
+ end
67
+ x_box do
68
+ label 'Some icons (C) Freeiconsweb http://www.freeiconsweb.com' do
69
+ foreground :GRAY; font 'Dialog',:BOLD,11
70
+ end
71
+ end
72
+ end
73
+ cheri_yield(panel,&block) if block
74
+ @panel
75
+ end
76
+ end #SplashScreen
77
+
78
+ end #Explorer
79
+ end #JRuby
80
+ end #Cheri
@@ -0,0 +1,619 @@
1
+ #--
2
+ # Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ #
24
+
25
+ module Cheri
26
+ module JRuby
27
+ module Explorer
28
+
29
+ # registered viewers
30
+ @viewers = {}
31
+ class << self
32
+ # TODO: interface for registering sub[-sub]* types - TypeViewer class does support it
33
+ # TODO: allow multiple viewer registrations for a type[/subtype] - user
34
+ # could switch via View menu or popup
35
+ def register_viewer(type,subtype,clazz)
36
+ raise Cheri.new_type_error(type,Symbol,Class) unless Symbol === type || Class === type
37
+ raise Cheri.new_type_error(clazz,Class) unless Class === clazz
38
+ if subtype
39
+ raise Cheri.new_type_error(subtype,Class,Symbol) unless Symbol === subtype || Class === subtype
40
+ end
41
+ if (tv = @viewers[type])
42
+ if subtype
43
+ sv = tv[subtype]
44
+ if sv
45
+ warn "replacing viewer for type #{type}/#{subtype} (#{sv.clazz}) with #{clazz}" if sv.clazz
46
+ sv.clazz = clazz
47
+ else
48
+ tv[subtype] = TypeViewer.new(subtype,clazz)
49
+ end
50
+ else
51
+ warn "replacing default viewer for type #{type} (#{tv.clazz}) with #{clazz}" if tv.clazz
52
+ tv.clazz = clazz
53
+ end
54
+ else
55
+ if subtype
56
+ #warn "adding viewer for type #{type}/#{subtype} when no default viewer for #{type}"
57
+ tv = TypeViewer.new(type,nil)
58
+ tv[subtype] = TypeViewer.new(subtype,clazz)
59
+ @viewers[type] = tv
60
+ else
61
+ @viewers[type] = TypeViewer.new(type,clazz)
62
+ end
63
+ end
64
+ end
65
+ def viewer(type,subtype=nil)
66
+ raise Cheri.new_type_error(type,Symbol,Class) unless Symbol === type || Class === type
67
+ raise Cheri.new_type_error(subtype,Symbol,Class,String) unless subtype.nil? ||
68
+ Symbol === subtype || Class === subtype || String === subtype
69
+ unless (tv = @viewers[type])
70
+ warn "no viewer found matching type: #{type} (#{subtype})"
71
+ return
72
+ end
73
+ if subtype
74
+ sv = tv[subtype]
75
+ # TODO: silently return default?
76
+ #warn "no viewer for subtype #{type}/#{subtype} - returning default for type" unless sv
77
+ sv || tv
78
+ else
79
+ tv
80
+ end
81
+ end
82
+
83
+ end #self
84
+
85
+ class TypeViewer
86
+ def initialize(type,clazz)
87
+ raise Cheri.new_type_error(type,Symbol,Class) unless Symbol === type || Class === type
88
+ raise Cheri.new_type_error(clazz,Class) unless clazz.nil? || Class === clazz
89
+ @t = type
90
+ @c = clazz if clazz
91
+ end
92
+ def type
93
+ @t
94
+ end
95
+ def clazz
96
+ @c
97
+ end
98
+ def clazz=(c)
99
+ raise Cheri.new_type_error(c,Class) unless Class === c
100
+ @c = c
101
+ end
102
+ def subtypes
103
+ @s
104
+ end
105
+ def []=(type,type_viewer)
106
+ raise Cheri.new_type_error(type,Symbol,Class) unless Symbol === type || Class === type
107
+ raise Cheri.new_type_error(type_viewer,TypeViewer) unless TypeViewer === type_viewer
108
+ (@s ||= {})[type] = type_viewer
109
+ end
110
+ def [](type)
111
+ raise Cheri.new_type_error(type,Symbol,Class,String) unless Symbol === type ||
112
+ Class === type || String === type
113
+ @s ? @s[type] : nil
114
+ end
115
+
116
+ # convenience method for instantiating +clazz+
117
+ def new(*r)
118
+ @c.new(*r) if @c
119
+ end
120
+ end #TypeViewer
121
+
122
+
123
+ class NodeType
124
+ def initialize(type,subtype=nil)
125
+ @t = type
126
+ @s = subtype if subtype
127
+ end
128
+ def type
129
+ @t
130
+ end
131
+ def subtype
132
+ @s
133
+ end
134
+ end
135
+ class NodeTypeValue < NodeType
136
+ def initialize(type,subtype,value)
137
+ super(type,subtype)
138
+ @v = value if value
139
+ end
140
+ def value
141
+ @v
142
+ end
143
+ end
144
+
145
+ module ViewerInterface
146
+ def initialize(node_type,main,instance,*r)
147
+ @type = node_type
148
+ @main = main
149
+ @instance = instance
150
+ end
151
+
152
+ # The node type of this viewer
153
+ def type
154
+ @type
155
+ end
156
+
157
+ def main
158
+ @main
159
+ end
160
+
161
+ def instance
162
+ @instance
163
+ end
164
+
165
+ def proxy
166
+ @instance.proxy
167
+ end
168
+
169
+ def title
170
+ @title
171
+ end
172
+
173
+ def title_tree
174
+ title
175
+ end
176
+
177
+ def title_tab
178
+ title
179
+ end
180
+
181
+ def icon
182
+ @icon
183
+ end
184
+
185
+ def icon_tree
186
+ icon
187
+ end
188
+
189
+ def icon_tab
190
+ icon
191
+ end
192
+
193
+ def tooltip
194
+ @tooltip
195
+ end
196
+
197
+ def leaf?
198
+ false
199
+ end
200
+
201
+ def view(&block)
202
+ if @view
203
+ @view.put_client_property(:viewer,self)
204
+ cheri_yield(@view,&block) if block
205
+ @view
206
+ end
207
+ end
208
+
209
+ def refresh
210
+ end
211
+
212
+ def tab(&block)
213
+ @tab ||= x_panel do
214
+ opaque false
215
+ label icon_tab
216
+ x_spacer 2
217
+ label title_tab
218
+ x_spacer 10
219
+ button CloseTabDimIcon do
220
+ rollover_icon CloseTabIcon
221
+ fixed_size 12,12
222
+ tool_tip_text 'Close'
223
+ content_area_filled false
224
+ border_painted false
225
+ on_click { close_view }
226
+ end
227
+ end
228
+ cheri_yield @tab, &block if block_given?
229
+ @tab
230
+ end
231
+
232
+ def close_view
233
+ @main.close_view(self)
234
+ end
235
+
236
+ end #ViewerInterface
237
+
238
+ module ValueViewerInterface
239
+ def initialize(node_type,main,instance,value,*r)
240
+ super
241
+ @value = value
242
+ end
243
+ def value
244
+ @value
245
+ end
246
+ end
247
+
248
+ module ParentViewerInterface
249
+ def children
250
+ @children
251
+ end
252
+
253
+ def children_loaded?
254
+ end
255
+
256
+ def load_children
257
+ end
258
+
259
+ def leaf?
260
+ false
261
+ end
262
+
263
+ end
264
+
265
+ class Viewer
266
+ include ViewerInterface
267
+ include Cheri::Swing
268
+
269
+ def initialize(*r)
270
+ super
271
+ swing[:auto => true]
272
+ end
273
+
274
+ end
275
+
276
+ class HtmlViewer < Viewer
277
+ include Cheri::Html
278
+ TblWidth = '98%'
279
+ TColor = '#080080'
280
+ HtmlStyle = %q[
281
+ .method { font-family: monospaced, courier; font-size: medium }
282
+ .oid { font-family: monospaced, courier; }
283
+ .var { font-family: monospaced, courier; font-weight: bold }
284
+ .val { font-family: monospaced, courier; color: #000080 }
285
+ .hdr { font-family: sans-serif; font-size: large; font-weight: bold; color: #000080 }
286
+ body { font-family: sans-serif; }
287
+ ]
288
+ ContType = 'text/html'.freeze
289
+
290
+ def html_style
291
+ HtmlStyle
292
+ end
293
+
294
+ def view(&block)
295
+ @view ||= scroll_pane do
296
+ align :LEFT
297
+ @html_view = editor_pane do
298
+ editable false
299
+ content_type ContType
300
+ html_document
301
+ end
302
+ end
303
+ super
304
+ end
305
+
306
+ def html_document
307
+ html do
308
+ head do
309
+ style html_style
310
+ end
311
+ # TODO: body attrs should be in style sheet
312
+ body :bgcolor => :white do
313
+ div :align => :left do
314
+ html_heading
315
+ html_content
316
+ end
317
+ end
318
+ end
319
+
320
+ end
321
+
322
+ def html_heading
323
+ html_title
324
+ end
325
+
326
+ def html_title
327
+ table :width => TblWidth, :cellspacing => 2, :cellpadding => 2, :border => 0 do
328
+ tr do
329
+ td esc(title), :class => :hdr, :align => :left, :colspan=> 2
330
+ end
331
+ end
332
+ #h2 title, :align => :left, :text => TColor
333
+ end
334
+
335
+ def html_content
336
+ end
337
+
338
+ def refresh
339
+ cheri_yield @html_view do
340
+ html_document
341
+ end
342
+ end
343
+ end
344
+
345
+ class HtmlTableViewer < HtmlViewer
346
+ def html_content
347
+ table :width => TblWidth, :cellspacing => 2, :cellpadding => 2, :border => 0 do
348
+ table_rows
349
+ nil
350
+ end
351
+ end
352
+
353
+ def table_rows
354
+ end
355
+
356
+ def empty_row
357
+ tr td('&nbsp;')
358
+ end
359
+
360
+ end
361
+
362
+ class HtmlNameValueListViewer < HtmlTableViewer
363
+ HColor = '#f0faff'.freeze
364
+ NColor = '#f0e2e0'.freeze
365
+ VColor = '#f0f0f0'.freeze
366
+ Right = 'right'.freeze
367
+ Top = 'top'.freeze
368
+
369
+ def name_value_row(name,value)
370
+ v = tr do
371
+ th name, :align => :left, :valign => Top, :width=> 160, :bgcolor => NColor
372
+ td value, :bgcolor => VColor, :class => :val
373
+ nil
374
+ end
375
+ v
376
+ end
377
+
378
+ def name_type_value_row(name,type,value)
379
+ tr do
380
+ th name, :class => :var, :align => :left, :valign => Top, :width=> 120, :bgcolor => NColor
381
+ td type, :bgcolor => VColor, :valign => Top
382
+ td value, :bgcolor => VColor, :class => :val
383
+ nil
384
+ end
385
+ end
386
+
387
+ def name_type_id_value_row(name,type,id,value)
388
+ tr do
389
+ td name, :class => :var, :valign => Top, :width=> 120, :bgcolor => VColor
390
+ td type, :bgcolor => VColor, :valign => Top
391
+ td id, :bgcolor => VColor, :align => Right, :valign => Top, :width => 20, :class => :oid
392
+ td value, :bgcolor => VColor, :class => :val
393
+ nil
394
+ end
395
+ end
396
+
397
+ def type_id_value_row(type,id,value)
398
+ tr do
399
+ td type, :bgcolor => VColor, :valign => Top
400
+ td id, :bgcolor => VColor, :align => Right, :valign => Top, :width => 20, :class => :oid
401
+ td value, :bgcolor => VColor, :class => :val
402
+ nil
403
+ end
404
+ end
405
+
406
+ def id_value_row(type,id,value)
407
+ tr do
408
+ td id, :bgcolor => VColor, :align => Right, :valign => Top, :width => 20, :class => :oid
409
+ td value, :bgcolor => VColor, :class => :val
410
+ nil
411
+ end
412
+ end
413
+
414
+ def value_list(value_array)
415
+ table do
416
+ value_array.each do |value|
417
+ tr td(esc(value))
418
+ end
419
+ nil
420
+ end
421
+ end
422
+
423
+ end #HtmlNameValueListViewer
424
+
425
+
426
+ module NavViewerConstants
427
+ Color = ::Java::JavaAwt::Color
428
+ Font = ::Java::JavaAwt::Font
429
+ TColor = Color.new(0,0,0x80)
430
+ NColor = Color.new(0xf0,0xe2,0xe0)
431
+ VColor = Color.new(0xf0,0xf0,0xf0)
432
+ HColor = Color.new(0xd0,0xe0,0xff)
433
+ TFont = Font.new('Dialog',Font::BOLD,18)
434
+ NFont = Font.new('Dialog',Font::BOLD,14)
435
+ VFont = Font.new('Monospaced',Font::PLAIN,14)
436
+ IFont = Font.new('Monospaced',Font::BOLD,14)
437
+ CFont = Font.new('Dialog',Font::PLAIN,14)
438
+ ResFont = Font.new('Monospaced',Font::PLAIN,12)
439
+ HdrName = 'Name'.freeze
440
+ HdrVarName = 'Variable name'.freeze
441
+ HdrType = 'Type'.freeze
442
+ HdrId = 'Id'.freeze
443
+ HdrValue = 'Value'.freeze
444
+ end
445
+
446
+ module NavViewer
447
+ include NavViewerConstants
448
+
449
+ class ColDef
450
+ attr :col, true
451
+ attr :hbg, true
452
+ attr :hfg, true
453
+ attr :hfont, true
454
+ attr :dbg, true
455
+ attr :dfg, true
456
+ attr :dfont, true
457
+ attr :dtext, true
458
+ attr :maxh, true
459
+ attr :clk, true
460
+ def initialize(hbg,hfg,hfont,dbg,dfg,dfont,dtext=nil,maxh=nil)
461
+ @hbg = hbg if hbg
462
+ @hfg = hfg if hfg
463
+ @hfont = hfont if hfont
464
+ @dbg = dbg if dbg
465
+ @dfg = dfg if dfg
466
+ @dfont = dfont if dfont
467
+ @dtext = dtext if dtext
468
+ @maxh = maxh if maxh
469
+ end
470
+ end
471
+
472
+ def initialize(*r)
473
+ super
474
+ swing[:auto]
475
+ end
476
+
477
+ def title_section(title)
478
+ x_box do
479
+ align :LEFT
480
+ label title do
481
+ align :LEFT
482
+ set_font TFont
483
+ foreground TColor
484
+ end
485
+ x_spacer 2
486
+ end
487
+ end
488
+
489
+ def init_cols(*coldefs)
490
+ coldefs.each do |cd|
491
+ cd.col = y_panel do
492
+ align :LEFT,:TOP
493
+ opaque false
494
+ end
495
+ end
496
+ end
497
+
498
+ def last_row(cols)
499
+ cols.each do |col|
500
+ cheri_yield col.col do
501
+ y_glue
502
+ end
503
+ end
504
+ end
505
+
506
+ def header_row(cols,*labels)
507
+ last = labels.length - 1
508
+ labels.length.times do |i|
509
+ col = cols[i] || cols.last
510
+ cheri_yield col.col do
511
+ x_panel do
512
+ align :LEFT,:TOP
513
+ background col.hbg || NColor
514
+ maximum_size 1000, 24
515
+ x_spacer 2
516
+ label labels[i] do
517
+ align :LEFT,:TOP
518
+ set_font col.hfont || NFont
519
+ foreground col.hfg if col.hfg
520
+ end
521
+ x_spacer 2
522
+ x_glue if i == last
523
+ end
524
+ x_spacer 1
525
+ y_spacer 2
526
+ end
527
+ end
528
+ cheri_yield cols.last.col do
529
+ x_glue
530
+ end
531
+ y_spacer 2
532
+ end
533
+
534
+ def value_row(cols,*values)
535
+ last = values.length - 1
536
+ values.length.times do |i|
537
+ col = cols[i] || cols.last
538
+ cheri_yield col.col do
539
+ #y_glue
540
+ x_panel do
541
+ align :LEFT,:TOP
542
+ background col.dbg || VColor
543
+ maximum_size 1000,col.maxh || 24
544
+ x_spacer 2
545
+ if col.clk
546
+ on_mouse_entered do |e|
547
+ e.source.background = HColor
548
+ end
549
+ on_mouse_exited do |e|
550
+ e.source.background = VColor
551
+ end
552
+ end
553
+ if col.dtext
554
+ text_area do
555
+ align :LEFT,:TOP
556
+ editable false
557
+ line_wrap true
558
+ set_font col.dfont || VFont
559
+ background col.dbg || VColor
560
+ foreground col.dfg if col.dfg
561
+ text values[i]
562
+ end
563
+ else
564
+ label values[i] do
565
+ align :LEFT,:TOP
566
+ set_font col.dfont || VFont
567
+ foreground col.dfg if col.dfg
568
+ if (click_val = col.clk)
569
+ on_mouse_clicked do
570
+ mouse_clicked(click_val)
571
+ end
572
+ on_mouse_entered do |e|
573
+ e.source.parent.background = HColor
574
+ end
575
+ on_mouse_exited do |e|
576
+ e.source.parent.background = VColor
577
+ end
578
+ end
579
+ end
580
+ end
581
+ x_spacer 2
582
+ x_glue if i == last
583
+ end
584
+ x_spacer 1
585
+ y_spacer 2
586
+ end
587
+ end
588
+ cheri_yield cols.last.col do
589
+ x_glue
590
+ end
591
+ y_spacer 2
592
+ end
593
+
594
+ def empty_row(glue=nil)
595
+ x_box do
596
+ align :LEFT,:TOP
597
+ spacer 1,12
598
+ end
599
+ y_glue if glue
600
+ end
601
+
602
+ def mouse_clicked(val)
603
+ end
604
+
605
+ end
606
+
607
+ module DRbHelper
608
+ # work around DRb (or possibly JRuby) issue iterating pseudo-array.
609
+ # TODO: need a client-side proxy for error handling and issues like this.
610
+ def drb_to_array(maybe_array)
611
+ return maybe_array if Array === maybe_array
612
+ Array.new(maybe_array.length) {|i| maybe_array[i]}
613
+ end
614
+
615
+ end
616
+
617
+ end #Explorer
618
+ end #JRuby
619
+ end #Cheri