cheri 0.0.9 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -143,33 +143,19 @@ class NodeTypeValue < NodeType
143
143
  end
144
144
 
145
145
  module ViewerInterface
146
+ attr_reader :type, :main, :instance
147
+ attr_accessor :title, :icon, :tooltip
148
+
146
149
  def initialize(node_type,main,instance,*r)
147
150
  @type = node_type
148
151
  @main = main
149
152
  @instance = instance
150
153
  end
151
154
 
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
155
  def proxy
166
156
  @instance.proxy
167
157
  end
168
158
 
169
- def title
170
- @title
171
- end
172
-
173
159
  def title_tree
174
160
  title
175
161
  end
@@ -178,10 +164,6 @@ module ViewerInterface
178
164
  title
179
165
  end
180
166
 
181
- def icon
182
- @icon
183
- end
184
-
185
167
  def icon_tree
186
168
  icon
187
169
  end
@@ -190,10 +172,6 @@ module ViewerInterface
190
172
  icon
191
173
  end
192
174
 
193
- def tooltip
194
- @tooltip
195
- end
196
-
197
175
  def leaf?
198
176
  false
199
177
  end
@@ -210,25 +188,24 @@ module ViewerInterface
210
188
  end
211
189
 
212
190
  def tab(&block)
213
- @tab ||= x_panel do
191
+ @tab ||= grid_table{
214
192
  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
193
+ grid_row{
194
+ label title_tab, icon_tab, :LEFT, :a=>:nw, :px=>10
195
+ button(CloseTabDimIcon, :a=>:ne) {
196
+ rollover_icon CloseTabIcon
197
+ fixed_size 12,12
198
+ tool_tip_text 'Close'
199
+ content_area_filled false
200
+ border_painted false
201
+ on_click { close_view }
202
+ }
203
+ }
204
+ }
228
205
  cheri_yield @tab, &block if block_given?
229
206
  @tab
230
207
  end
231
-
208
+
232
209
  def close_view
233
210
  @main.close_view(self)
234
211
  end
@@ -236,19 +213,17 @@ module ViewerInterface
236
213
  end #ViewerInterface
237
214
 
238
215
  module ValueViewerInterface
216
+ attr_reader :value
217
+
239
218
  def initialize(node_type,main,instance,value,*r)
240
219
  super
241
220
  @value = value
242
221
  end
243
- def value
244
- @value
245
- end
246
- end
222
+
223
+ end #ValueViewerInterface
247
224
 
248
225
  module ParentViewerInterface
249
- def children
250
- @children
251
- end
226
+ attr_reader :children
252
227
 
253
228
  def children_loaded?
254
229
  end
@@ -260,7 +235,7 @@ module ParentViewerInterface
260
235
  false
261
236
  end
262
237
 
263
- end
238
+ end #ParentViewerInterface
264
239
 
265
240
  class Viewer
266
241
  include ViewerInterface
@@ -285,7 +260,7 @@ class HtmlViewer < Viewer
285
260
  .hdr { font-family: sans-serif; font-size: large; font-weight: bold; color: #000080 }
286
261
  body { font-family: sans-serif; }
287
262
  ]
288
- ContType = 'text/html'.freeze
263
+ ContType = 'text/html'
289
264
 
290
265
  def html_style
291
266
  HtmlStyle
@@ -360,11 +335,11 @@ class HtmlTableViewer < HtmlViewer
360
335
  end
361
336
 
362
337
  class HtmlNameValueListViewer < HtmlTableViewer
363
- HColor = '#f0faff'.freeze
364
- NColor = '#f0e2e0'.freeze
365
- VColor = '#f0f0f0'.freeze
366
- Right = 'right'.freeze
367
- Top = 'top'.freeze
338
+ HColor = '#f0faff'
339
+ NColor = '#f0e2e0'
340
+ VColor = '#f0f0f0'
341
+ Right = 'right'
342
+ Top = 'top'
368
343
 
369
344
  def name_value_row(name,value)
370
345
  v = tr do
@@ -422,7 +397,8 @@ class HtmlNameValueListViewer < HtmlTableViewer
422
397
 
423
398
  end #HtmlNameValueListViewer
424
399
 
425
-
400
+ # FIXME: Keeping this deprecated module for now, since it's used
401
+ # in ResultListViewer.
426
402
  module NavViewerConstants
427
403
  Color = ::Java::JavaAwt::Color
428
404
  Font = ::Java::JavaAwt::Font
@@ -430,6 +406,8 @@ module NavViewerConstants
430
406
  NColor = Color.new(0xf0,0xe2,0xe0)
431
407
  VColor = Color.new(0xf0,0xf0,0xf0)
432
408
  HColor = Color.new(0xd0,0xe0,0xff)
409
+ White = Color::WHITE
410
+ Black = Color::BLACK
433
411
  TFont = Font.new('Dialog',Font::BOLD,18)
434
412
  NFont = Font.new('Dialog',Font::BOLD,14)
435
413
  VFont = Font.new('Monospaced',Font::PLAIN,14)
@@ -441,167 +419,90 @@ module NavViewerConstants
441
419
  BUTTON2 = MouseEvent::BUTTON2
442
420
  BUTTON3 = MouseEvent::BUTTON3
443
421
  SHIFT = MouseEvent::SHIFT_DOWN_MASK
444
- HdrName = 'Name'.freeze
445
- HdrVarName = 'Variable name'.freeze
446
- HdrType = 'Type'.freeze
447
- HdrId = 'Id'.freeze
448
- HdrValue = 'Value'.freeze
422
+ HdrName = 'Name'
423
+ HdrVarName = 'Variable name'
424
+ HdrType = 'Type'
425
+ HdrId = 'Id'
426
+ HdrValue = 'Value'
449
427
  end
450
428
 
451
- module NavViewer
452
- include NavViewerConstants
453
-
454
- class ColDef
455
- attr :col, true
456
- attr :hbg, true
457
- attr :hfg, true
458
- attr :hfont, true
459
- attr :dbg, true
460
- attr :dfg, true
461
- attr :dfont, true
462
- attr :dtext, true
463
- attr :maxh, true
464
- attr :clk, true
465
- def initialize(hbg,hfg,hfont,dbg,dfg,dfont,dtext=nil,maxh=nil)
466
- @hbg = hbg if hbg
467
- @hfg = hfg if hfg
468
- @hfont = hfont if hfont
469
- @dbg = dbg if dbg
470
- @dfg = dfg if dfg
471
- @dfont = dfont if dfont
472
- @dtext = dtext if dtext
473
- @maxh = maxh if maxh
474
- end
475
- end
429
+ module GBLViewer
430
+ import java.awt.Color
431
+ import java.awt.Font
432
+ import java.awt.Insets
433
+ import java.awt.event.MouseEvent
434
+ import javax.swing.SwingConstants
435
+
436
+ White = Color::WHITE
437
+ Black = Color::BLACK
438
+ TColor = Color.new(0,0,0x80)
439
+ NColor = Color.new(0xf0,0xe2,0xe0)
440
+ VColor = Color.new(0xf0,0xf0,0xf0)
441
+ HColor = Color.new(0xd0,0xe0,0xff)
442
+
443
+ TFont = Font.new('Dialog',Font::BOLD,18)
444
+ NFont = Font.new('Dialog',Font::BOLD,14)
445
+ VFont = Font.new('Monospaced',Font::PLAIN,14)
446
+ IFont = Font.new('Monospaced',Font::BOLD,14)
447
+ CFont = Font.new('Dialog',Font::PLAIN,14)
448
+ ResFont = Font.new('Monospaced',Font::PLAIN,12)
449
+
450
+ SHIFT = MouseEvent::SHIFT_DOWN_MASK
451
+ BUTTON1 = MouseEvent::BUTTON1
452
+ BUTTON2 = MouseEvent::BUTTON2
453
+ BUTTON3 = MouseEvent::BUTTON3
454
+
455
+ TOP = SwingConstants::TOP
456
+
457
+ LabelBorder = javax.swing.border.EmptyBorder.new 0,2,0,0
458
+ LineInset = Insets.new 1,0,0,0
459
+ CellInset = Insets.new 0,0,1,1
460
+ HeaderInset = Insets.new 12,0,1,1
476
461
 
477
462
  def initialize(*r)
478
463
  super
479
464
  swing[:auto]
480
465
  end
481
466
 
482
- def title_section(title)
483
- x_box do
484
- align :LEFT
485
- label title do
486
- align :LEFT
487
- set_font TFont
488
- foreground TColor
489
- end
490
- x_spacer 2
467
+ def cell_label(text,font=ResFont,bgcolor=White,fgcolor=Black,*opts)
468
+ label(text, *opts) do
469
+ vertical_alignment TOP
470
+ border LabelBorder
471
+ opaque true
472
+ background bgcolor
473
+ foreground fgcolor
474
+ set_font font
491
475
  end
492
476
  end
493
477
 
494
- def init_cols(*coldefs)
495
- coldefs.each do |cd|
496
- cd.col = y_panel do
497
- align :LEFT,:TOP
498
- opaque false
499
- end
478
+ def value_label(value,font=ResFont,bgcolor=White,fgcolor=Black,*opts)
479
+ # not actually a label but a text area to support multiple lines
480
+ text_area(*opts) do
481
+ border LabelBorder
482
+ opaque true
483
+ editable false
484
+ line_wrap true
485
+ background bgcolor
486
+ foreground fgcolor
487
+ set_font font
488
+ text value
500
489
  end
501
490
  end
502
-
503
- def last_row(cols)
504
- cols.each do |col|
505
- cheri_yield col.col do
506
- y_glue
507
- end
508
- end
509
- end
510
491
 
511
- def header_row(cols,*labels)
512
- last = labels.length - 1
513
- labels.length.times do |i|
514
- col = cols[i] || cols.last
515
- cheri_yield col.col do
516
- x_panel do
517
- align :LEFT,:TOP
518
- background col.hbg || NColor
519
- maximum_size 1000, 24
520
- x_spacer 2
521
- label labels[i] do
522
- align :LEFT,:TOP
523
- set_font col.hfont || NFont
524
- foreground col.hfg if col.hfg
525
- end
526
- x_spacer 2
527
- x_glue if i == last
528
- end
529
- x_spacer 1
530
- y_spacer 2
531
- end
532
- end
533
- cheri_yield cols.last.col do
534
- x_glue
492
+ def click_label(text,id,font=ResFont,bgcolor=White,altcolor=bgcolor,fgcolor=Black,*opts)
493
+ label(text, *opts) do
494
+ vertical_alignment TOP
495
+ border LabelBorder
496
+ opaque true
497
+ background bgcolor
498
+ foreground fgcolor
499
+ set_font font
500
+ on_mouse_entered {|e| e.source.background = altcolor}
501
+ on_mouse_exited {|e| e.source.background = bgcolor}
502
+ on_mouse_clicked {|e| mouse_clicked(e,id) }
503
+ on_mouse_pressed {|e| mouse_action(e,id) }
504
+ on_mouse_released {|e| mouse_action(e,id) }
535
505
  end
536
- y_spacer 2
537
- end
538
-
539
- def value_row(cols,*values)
540
- last = values.length - 1
541
- values.length.times do |i|
542
- col = cols[i] || cols.last
543
- cheri_yield col.col do
544
- #y_glue
545
- x_panel do
546
- align :LEFT,:TOP
547
- background col.dbg || VColor
548
- maximum_size 1000,col.maxh || 24
549
- x_spacer 2
550
- if col.clk
551
- on_mouse_entered do |e|
552
- e.source.background = HColor
553
- end
554
- on_mouse_exited do |e|
555
- e.source.background = VColor
556
- end
557
- end
558
- if col.dtext
559
- text_area do
560
- align :LEFT,:TOP
561
- editable false
562
- line_wrap true
563
- set_font col.dfont || VFont
564
- background col.dbg || VColor
565
- foreground col.dfg if col.dfg
566
- text values[i]
567
- end
568
- else
569
- label values[i] do
570
- align :LEFT,:TOP
571
- set_font col.dfont || VFont
572
- foreground col.dfg if col.dfg
573
- if (click_val = col.clk)
574
- on_mouse_entered do |e|
575
- e.source.parent.background = HColor
576
- end
577
- on_mouse_exited do |e|
578
- e.source.parent.background = VColor
579
- end
580
- on_mouse_clicked {|e| mouse_clicked(e,click_val) }
581
- on_mouse_pressed {|e| mouse_action(e,click_val) }
582
- on_mouse_released {|e| mouse_action(e,click_val) }
583
- end
584
- end
585
- end
586
- x_spacer 2
587
- x_glue if i == last
588
- end
589
- x_spacer 1
590
- y_spacer 2
591
- end
592
- end
593
- cheri_yield cols.last.col do
594
- x_glue
595
- end
596
- y_spacer 2
597
- end
598
-
599
- def empty_row(glue=nil)
600
- x_box do
601
- align :LEFT,:TOP
602
- spacer 1,12
603
- end
604
- y_glue if glue
605
506
  end
606
507
 
607
508
  def mouse_clicked(e,val=nil)
@@ -610,7 +511,19 @@ module NavViewer
610
511
  def mouse_action(e,val=nil)
611
512
  end
612
513
 
613
- end
514
+ def header_row(header_list,font=ResFont,bgcolor=White,fgcolor=Black,opts={})
515
+ grid_row(opts) {
516
+ size = header_list.size
517
+ last = size - 1
518
+ wx = 0.0
519
+ size.times {|i|
520
+ wx = 0.1 if i == last
521
+ cell_label(header_list[i],font,bgcolor,fgcolor,:wx=>wx)
522
+ }
523
+ }
524
+ end
525
+
526
+ end #GBLViewer
614
527
 
615
528
  module DRbHelper
616
529
  # work around DRb (or possibly JRuby) issue iterating pseudo-array.
@@ -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
@@ -71,13 +71,13 @@ class RubyInstanceViewer < HtmlNameValueListViewer
71
71
  end #RubyInstanceViewer
72
72
 
73
73
  class JRubyInstanceViewer < RubyInstanceViewer
74
- JVersion = 'java.version'.freeze
75
- JVendor = 'java.vendor'.freeze
76
- RtName = 'java.runtime.name'.freeze
77
- RtVersion = 'java.runtime.version'.freeze
78
- VmName = 'java.vm.name'.freeze
79
- VmVersion = 'java.vm.version'.freeze
80
- VmVendor = 'java.vm.vendor'.freeze
74
+ JVersion = 'java.version'
75
+ JVendor = 'java.vendor'
76
+ RtName = 'java.runtime.name'
77
+ RtVersion = 'java.runtime.version'
78
+ VmName = 'java.vm.name'
79
+ VmVersion = 'java.vm.version'
80
+ VmVendor = 'java.vm.vendor'
81
81
 
82
82
  def table_rows
83
83
  super
@@ -289,15 +289,15 @@ class ObjectViewer < HtmlNameValueListViewer
289
289
  include ValueViewerInterface
290
290
 
291
291
  #:stopdoc:
292
- HdrInstVars = 'Instance variables'.freeze
293
- HdrInstVarName = 'Variable name'.freeze
294
- HdrName = 'Name'.freeze
295
- HdrType = 'Type'.freeze
296
- HdrId = 'Id'.freeze
297
- HdrValue = 'Value'.freeze
298
- Center = 'center'.freeze
299
- Left = 'left'.freeze
300
- Right = 'right'.freeze
292
+ HdrInstVars = 'Instance variables'
293
+ HdrInstVarName = 'Variable name'
294
+ HdrName = 'Name'
295
+ HdrType = 'Type'
296
+ HdrId = 'Id'
297
+ HdrValue = 'Value'
298
+ Center = 'center'
299
+ Left = 'left'
300
+ Right = 'right'
301
301
  #:startdoc:
302
302
 
303
303
  def title
@@ -361,7 +361,6 @@ class ObjectViewer < HtmlNameValueListViewer
361
361
  end
362
362
 
363
363
  class ConstantViewer < ObjectViewer
364
- HdrConstName = 'Constant name'.freeze
365
364
  def title
366
365
  "#{@instance.name}: #{@value.qname}"
367
366
  end
@@ -376,7 +375,7 @@ class ConstantViewer < ObjectViewer
376
375
  end
377
376
 
378
377
  def table_rows
379
- col_header_row HdrConstName
378
+ col_header_row 'Constant name'
380
379
  name_type_id_value_row(@value.name,esc(@value.clazz),@value.id,esc(@value.value))
381
380
  instance_var_rows if @value.vars
382
381
  end
@@ -387,9 +386,9 @@ class ModuleViewer < ConstantViewer
387
386
  include ParentViewerInterface
388
387
  include DRbHelper
389
388
  #:stopdoc:
390
- SuperClazz = 'Superclass'.freeze
391
- Ancestors = 'Ancestors'.freeze
392
- HdrAncName = 'Ancestor name'.freeze
389
+ SuperClazz = 'Superclass'
390
+ Ancestors = 'Ancestors'
391
+ HdrAncName = 'Ancestor name'
393
392
  #:startdoc:
394
393
 
395
394
  def title
@@ -459,44 +458,35 @@ class ModuleViewer < ConstantViewer
459
458
  method_rows
460
459
  end
461
460
 
462
- #:stopdoc:
463
- HdrPubClsMeth = 'Public class methods'.freeze
464
- HdrPubInsMeth = 'Public instance methods'.freeze
465
- HdrProClsMeth = 'Protected class methods'.freeze
466
- HdrProInsMeth = 'Protected instance methods'.freeze
467
- HdrPriClsMeth = 'Private class methods'.freeze
468
- HdrPriInsMeth = 'Private instance methods'.freeze
469
- #:startdoc:
470
-
471
461
  def method_rows
472
462
  if (meths = @methods ||= proxy.module_methods(@value.qname,@value.id))
473
463
  if (ms = meths.pub) && !ms.empty?
474
- method_header_row HdrPubClsMeth
464
+ method_header_row 'Public class methods'
475
465
  ms.sort.each do |m| method_row(m); end
476
466
  empty_row
477
467
  end
478
468
  if (ms = meths.pub_inst) && !ms.empty?
479
- method_header_row HdrPubInsMeth
469
+ method_header_row 'Public instance methods'
480
470
  ms.sort.each do |m| method_row(m); end
481
471
  empty_row
482
472
  end
483
473
  if (ms = meths.pro) && !ms.empty?
484
- method_header_row HdrProClsMeth
474
+ method_header_row 'Protected class methods'
485
475
  ms.sort.each do |m| method_row(m); end
486
476
  empty_row
487
477
  end
488
478
  if (ms = meths.pro_inst) && !ms.empty?
489
- method_header_row HdrProInsMeth
479
+ method_header_row 'Protected instance methods'
490
480
  ms.sort.each do |m| method_row(m); end
491
481
  empty_row
492
482
  end
493
483
  if (ms = meths.pri) && !ms.empty?
494
- method_header_row HdrPriClsMeth
484
+ method_header_row 'Private class methods'
495
485
  ms.sort.each do |m| method_row(m); end
496
486
  empty_row
497
487
  end
498
488
  if (ms = meths.pri_inst) && !ms.empty?
499
- method_header_row HdrPriInsMeth
489
+ method_header_row 'Private instance methods'
500
490
  ms.sort.each do |m| method_row(m); end
501
491
  empty_row
502
492
  end
@@ -513,15 +503,13 @@ class ModuleViewer < ConstantViewer
513
503
  tr td(esc(meth), :class => :method, :bgcolor => VColor, :colspan => cols)
514
504
  end
515
505
 
516
- Cls = 'Class'.freeze #:nodoc:
517
- Mod = 'Module'.freeze #:nodoc:
518
506
  def load_children
519
507
  recs = drb_to_array(proxy.const_recs(value.qname)).sort
520
508
  children = []
521
509
  recs.each do |rec|
522
510
  ntv = case rec.clazz
523
- when Cls : NodeTypeValue.new(Class,rec.value,rec)
524
- when Mod : NodeTypeValue.new(Module,rec.value,rec)
511
+ when 'Class' : NodeTypeValue.new(Class,rec.value,rec)
512
+ when 'Module' : NodeTypeValue.new(Module,rec.value,rec)
525
513
  else NodeTypeValue.new(:constant,rec.clazz,rec)
526
514
  end
527
515
  children << ntv
@@ -820,298 +808,102 @@ class ResultListViewer < Viewer
820
808
  end
821
809
  end
822
810
 
823
-
824
- class NavObjectViewer
811
+ class GBLObjectViewer
825
812
  include ViewerInterface
826
813
  include ValueViewerInterface
827
- include NavViewer
828
- include Cheri::Swing
814
+ include GBLViewer
829
815
 
816
+ include Cheri::Swing
817
+
830
818
  def title
831
- "#{@instance.name}: #{@value.clazz}"
819
+ "#{@instance.name}: #{@value.clazz} value"
832
820
  end
821
+
833
822
  def title_tree
834
823
  "#{@value.clazz}"
835
824
  end
825
+
836
826
  def title_tab
837
- "#{@instance.name}: #{@value.clazz}"
827
+ title
838
828
  end
829
+
839
830
  def icon
840
831
  ObjectIcon
841
832
  end
833
+
842
834
  def leaf?
843
835
  true
844
836
  end
845
837
 
846
- def content_section
847
- empty_row
848
- value_section
849
- if @value.vars
850
- empty_row
851
- variables_section
852
- last_row(@icols)
853
- else
854
- last_row(@vcols)
855
- end
856
- empty_row true
857
- end
858
-
859
- def value_section
860
- idcol = ColDef.new(NColor,nil,NFont,VColor,nil,CFont)
861
- typecol = ColDef.new(NColor,nil,NFont,VColor,nil,CFont)
862
- valcol = ColDef.new(NColor,nil,NFont,VColor,TColor,VFont,true,10000)
863
-
864
- @vcols = [idcol,typecol,valcol]
865
- @vsec = x_box do
866
- init_cols(*@vcols)
867
- align :LEFT,:TOP
868
- end
869
- header_row(@vcols,HdrId,HdrType,HdrValue)
870
- value_row(@vcols,@value.id.to_s,@value.clazz,@value.value)
871
- end
872
-
873
- def variables_section
874
- return unless (vars = value.vars)
875
- idcol = ColDef.new(NColor,nil,NFont,VColor,nil,CFont)
876
- namecol = ColDef.new(NColor,nil,NFont,VColor,nil,IFont)
877
- typecol = ColDef.new(NColor,nil,NFont,VColor,nil,CFont)
878
- valcol = ColDef.new(NColor,nil,NFont,VColor,TColor,VFont)
879
-
880
- @icols = [idcol,namecol,typecol,valcol]
881
- @isec = x_box do
882
- init_cols(*@icols)
883
- align :LEFT,:TOP
884
- end
885
- header_row(@icols,HdrId,HdrVarName,HdrType,HdrValue)
886
- vars.each do |name,type,value,id|
887
- idcol.clk = id
888
- namecol.clk = id
889
- value_row(@icols,id.to_s,name,type,value)
890
- end
891
- end
892
-
893
- def send_selection(id,new_tab=nil)
894
- @main.show_linked_object(self,id,new_tab)
895
- end
838
+ def view
839
+ @view ||= scroll_pane {
840
+ grid_table{ #Body
841
+ background :WHITE
842
+ opaque true
843
+ defaults :a=>:nw, :wx=>0.1, :wy=>0.0, :f=>:h
844
+ grid_row{ #Title
845
+ cell_label title, TFont, White, TColor
846
+ } #Title
847
+ grid_row{ #Value
848
+ grid_table{
849
+ defaults :a=>:nw, :wx=>0.0, :wy=>0.0, :f=>:h, :i=>CellInset
850
+ opaque false
851
+ header_row ['Id','Type','Value'], NFont, NColor, Black, :px=>16
896
852
 
897
- def mouse_clicked(e,id)
898
- send_selection(id,(e.modifiers_ex & SHIFT) == SHIFT)
899
- end
853
+ grid_row(:f=>:both, :wy=>0.1, :px=>12){
854
+ cell_label @value.id.to_s, VFont, VColor, Black
855
+ cell_label @value.clazz, VFont, VColor, Black
856
+ value_label @value.value, VFont, VColor, Black, :px=>0, :wx=>0.1
857
+ }
858
+ }
859
+ } #Value
900
860
 
901
- def mouse_action(e,id)
902
- if e.popup_trigger?
903
- @menu_pending = id
904
- selection_popup.show(e.component,e.x,e.y)
905
- end
906
- end
907
-
908
- def menu_selection(new_tab)
909
- if id = @menu_pending
910
- @menu_pending = nil
911
- send_selection(id,new_tab)
912
- end
913
- end
914
-
915
- def selection_popup
916
- @popup ||= popup_menu 'Open item in ... ' do
917
- menu_item 'Open in new tab' do
918
- on_click {menu_selection true}
919
- end
920
- menu_item 'Open in default tab' do
921
- on_click {menu_selection false}
922
- end
923
- end
861
+ # FIXME: forcing stuff upwards; there *must* be a better way...
862
+ grid_row{empty_cell(:a=>:se, :wy=>0.1, :f=>:v)}
863
+ } #Body
864
+ } # scroll_pane
924
865
  end
925
866
 
926
-
927
- def view(&block)
928
- @view ||= scroll_pane do
929
- align :LEFT
930
- @top_view = y_panel do
931
- align :LEFT
932
- empty_border 4,4,4,4
933
- background :WHITE
934
- title_section title
935
- content_section
936
- end
937
- end
938
- end
867
+ end #GBLObjectViewer
939
868
 
940
- end #NavObjectViewer
941
-
942
- class NavModuleViewer
869
+ class GBLModuleViewer
943
870
  include ViewerInterface
944
871
  include ValueViewerInterface
945
872
  include ParentViewerInterface
946
- include NavViewer
873
+ include GBLViewer
874
+
947
875
  include Cheri::Swing
948
876
  include DRbHelper
949
- #:stopdoc:
950
- SuperClazz = 'Superclass'.freeze
951
- Ancestors = 'Ancestors'.freeze
952
- HdrAncName = 'Ancestor name'.freeze
953
- HdrPubClsMeth = 'Public class methods'.freeze
954
- HdrPubInsMeth = 'Public instance methods'.freeze
955
- HdrProClsMeth = 'Protected class methods'.freeze
956
- HdrProInsMeth = 'Protected instance methods'.freeze
957
- HdrPriClsMeth = 'Private class methods'.freeze
958
- HdrPriInsMeth = 'Private instance methods'.freeze
959
- #:startdoc:
960
877
 
961
-
962
878
  def title
963
879
  "#{@instance.name}: #{@value.qname.empty? ? @value.value : @value.qname}"
964
880
  end
881
+
965
882
  def title_tree
966
883
  "#{@value.name}"
967
884
  end
885
+
968
886
  def title_tab
969
887
  "#{@instance.name}: #{@value.name.empty? ? @value.value : @value.name}"
970
888
  end
889
+
971
890
  def icon
972
891
  ModuleIcon
973
892
  end
893
+
974
894
  def leaf?
975
895
  false
976
896
  end
977
897
 
978
- def content_section
979
- val = @value
980
- header_section
981
- empty_row
982
- if (anc = val.ancestors) && (first = anc.first)
983
- anc.shift if first.id == val.id && first.value == val.qname
984
- end
985
- if anc && !anc.empty?
986
- ancestor_section
987
- empty_row
988
- end
989
- if val.vars
990
- variables_section
991
- empty_row
992
- end
993
- methods_section
994
- last_row @last_cols
995
- empty_row true
996
- end
997
-
998
- def header_section
999
- namecol = ColDef.new(NColor,nil,NFont,NColor,nil,NFont)
1000
- valcol = ColDef.new(VColor,nil,CFont,VColor,nil,CFont)
1001
-
1002
- @hcols = [namecol,valcol]
1003
- @hsec = x_box do
1004
- init_cols(*@hcols)
1005
- align :LEFT,:TOP
1006
- end
1007
- val = @value
1008
- header_row(@hcols,val.clazz, val.qname.empty? ? val.value : val.qname)
1009
- header_row(@hcols,HdrId,val.id.to_s)
1010
- if (sc = val.superclazz)
1011
- header_row(@hcols,SuperClazz,sc)
1012
- end
1013
- @last_cols = @hcols
1014
- end
1015
-
1016
- def ancestor_section
1017
- idcol = ColDef.new(NColor,nil,NFont,VColor,nil,CFont)
1018
- namecol = ColDef.new(NColor,nil,NFont,VColor,nil,CFont)
1019
- typecol = ColDef.new(NColor,nil,NFont,VColor,nil,CFont)
1020
-
1021
- @acols = [idcol,namecol,typecol]
1022
- @asec = x_box do
1023
- init_cols(*@acols)
1024
- align :LEFT,:TOP
1025
- end
1026
- header_row(@acols,HdrId,HdrAncName,HdrType)
1027
- @value.ancestors.each do |name,type,id|
1028
- idcol.clk = id
1029
- namecol.clk = id
1030
- value_row(@acols,id.to_s,name,type)
1031
- end
1032
- @last_cols = @acols
1033
- end
1034
-
1035
- def variables_section
1036
- return unless (vars = value.vars)
1037
- idcol = ColDef.new(NColor,nil,NFont,VColor,nil,CFont)
1038
- namecol = ColDef.new(NColor,nil,NFont,VColor,nil,IFont)
1039
- typecol = ColDef.new(NColor,nil,NFont,VColor,nil,CFont)
1040
- valcol = ColDef.new(NColor,nil,NFont,VColor,TColor,VFont)
1041
-
1042
- @icols = [idcol,namecol,typecol,valcol]
1043
- @isec = x_box do
1044
- init_cols(*@icols)
1045
- align :LEFT,:TOP
1046
- end
1047
- header_row(@icols,HdrId,HdrVarName,HdrType,HdrValue)
1048
- vars.each do |name,type,value,id|
1049
- idcol.clk = id
1050
- namecol.clk = id
1051
- value = value + '...' if value.length == 100
1052
- value_row(@icols,id.to_s,name,type,value)
1053
- end
1054
- @last_cols = @icols
1055
- end
1056
-
1057
- def methods_section
1058
- return unless (meths = @methods ||= proxy.module_methods(@value.qname,@value.id))
1059
- coldef = ColDef.new(NColor,nil,NFont,VColor,nil,VFont)
1060
-
1061
- @mcols = [coldef]
1062
- @msec = x_box do
1063
- init_cols(*@mcols)
1064
- align :LEFT,:TOP
1065
- end
1066
- if (ms = meths.pub) && !ms.empty?
1067
- header_row(@mcols,HdrPubClsMeth)
1068
- ms.sort.each do |m|
1069
- value_row(@mcols,m)
1070
- end
1071
- end
1072
- if (ms = meths.pub_inst) && !ms.empty?
1073
- header_row(@mcols,HdrPubInsMeth)
1074
- ms.sort.each do |m|
1075
- value_row(@mcols,m)
1076
- end
1077
- end
1078
- if (ms = meths.pro) && !ms.empty?
1079
- header_row(@mcols,HdrProClsMeth)
1080
- ms.sort.each do |m|
1081
- value_row(@mcols,m)
1082
- end
1083
- end
1084
- if (ms = meths.pro_inst) && !ms.empty?
1085
- header_row(@mcols,HdrProInsMeth)
1086
- ms.sort.each do |m|
1087
- value_row(@mcols,m)
1088
- end
1089
- end
1090
- if (ms = meths.pri) && !ms.empty?
1091
- header_row(@mcols,HdrPriClsMeth)
1092
- ms.sort.each do |m|
1093
- value_row(@mcols,m)
1094
- end
1095
- end
1096
- if (ms = meths.pri_inst) && !ms.empty?
1097
- header_row(@mcols, HdrPriInsMeth)
1098
- ms.sort.each do |m|
1099
- value_row(@mcols,m)
1100
- end
1101
- end
1102
- @last_cols = @mcols
1103
- end
1104
-
1105
- Cls = 'Class'.freeze #:nodoc:
1106
- Mod = 'Module'.freeze #:nodoc:
1107
898
  def load_children
1108
899
  recs = drb_to_array(proxy.const_recs(value.qname)).sort
1109
900
  children = []
1110
901
  recs.each do |rec|
1111
902
  ntv = case rec.clazz
1112
- when Cls : NodeTypeValue.new(Class,rec.value,rec)
1113
- when Mod : NodeTypeValue.new(Module,rec.value,rec)
903
+ when 'Class' : NodeTypeValue.new(Class,rec.value,rec)
904
+ when 'Module' : NodeTypeValue.new(Module,rec.value,rec)
1114
905
  else NodeTypeValue.new(:constant,rec.clazz,rec)
906
+
1115
907
  end
1116
908
  children << ntv
1117
909
  end
@@ -1119,9 +911,9 @@ class NavModuleViewer
1119
911
  end
1120
912
 
1121
913
  def children_loaded?
1122
- @children
914
+ !!@children
1123
915
  end
1124
-
916
+
1125
917
  def send_selection(id,new_tab=nil)
1126
918
  @main.show_linked_object(self,id,new_tab)
1127
919
  end
@@ -1154,30 +946,151 @@ class NavModuleViewer
1154
946
  end
1155
947
  end
1156
948
  end
949
+
950
+ def title_section
951
+ grid_row{
952
+ cell_label title, TFont, White, TColor
953
+ }
954
+ end
955
+
956
+ def header_section
957
+ val = @value
958
+ grid_row{ #Header
959
+ grid_table {
960
+ defaults :a=>:nw, :f=>:both, :wx=>0.0, :wy=>0.0, :i=>CellInset
961
+ opaque false
962
+ grid_row{
963
+ cell_label 'Module', NFont, NColor, Black
964
+ cell_label(val.qname.empty? ? val.value : val.qname, VFont, VColor, Black, :wx=>0.1)
965
+ }
966
+ grid_row{
967
+ cell_label 'Id', NFont, NColor, Black
968
+ cell_label(val.id.to_s, VFont, VColor, Black, :wx=>0.1)
969
+ }
970
+ }
971
+ } #Header
972
+ end
973
+
974
+ def ancestors_section
975
+ val = @value
976
+ if (anc = val.ancestors) && (first = anc.first)
977
+ anc.shift if first.id == val.id && first.value == val.qname
978
+ end
979
+ return unless anc && !anc.empty?
980
+
981
+ grid_row{ #Ancestors
982
+ grid_table {
983
+ defaults :a=>:nw, :f=>:h, :wx=>0.0
984
+ opaque false
985
+ header_row ['Id', 'Ancestor name', 'Type'], NFont, NColor, Black, :px=>16, :i=>[16,0,1,1]
986
+ anc.each {|name,type,id|
987
+ grid_row(:i=>[0,0,1,1], :f=>:both, :a=>:nw, :wy=>0.1, :px=>12){
988
+ click_label id.to_s, id, VFont, VColor, Color::CYAN, Black
989
+ click_label name, id, VFont, VColor, Color::CYAN, Black
990
+ cell_label type, VFont, VColor, Black
991
+ }
992
+ }
993
+ }
994
+ } #Ancestors
995
+ end
1157
996
 
997
+ def variables_section
998
+ val = @value
999
+ return unless (vars = val.vars) && !vars.empty?
1000
+
1001
+ grid_row{ #Variables
1002
+ grid_table {
1003
+ defaults :a=>:nw, :f=>:h, :wx=>0.0
1004
+ opaque false
1005
+ header_row ['Id', 'Variable name', 'Type', 'Value'], NFont, NColor, Black, :px=>16, :i=>[16,0,1,1]
1006
+ vars.each {|name,type,value,id|
1007
+ value = value + '...' if value.length >= 100
1008
+ grid_row(:i=>[0,0,1,1], :f=>:both, :a=>:nw, :wy=>0.1, :px=>12){
1009
+ click_label id.to_s, id, CFont, VColor, Color::CYAN, Black
1010
+ click_label name, id, IFont, VColor, Color::CYAN, Black
1011
+ cell_label type, CFont, VColor, Black
1012
+ value_label value, VFont, VColor, TColor, :px=>0, :wx=>0.0
1013
+ }
1014
+ }
1015
+ }
1016
+ } #Variables
1017
+ end
1158
1018
 
1159
- def view(&block)
1160
- @view ||= scroll_pane do
1161
- align :LEFT
1162
- @top_view = y_panel do
1163
- align :LEFT
1164
- empty_border 4,4,4,4
1019
+ def methods_section
1020
+ return unless (methods = @methods ||= proxy.module_methods(@value.qname,@value.id))
1021
+ [
1022
+ [methods.pub,'Public class methods'],
1023
+ [methods.pub_inst,'Public instance methods'],
1024
+ [methods.pro,'Protected class methods'],
1025
+ [methods.pro_inst,'Protected instance methods'],
1026
+ [methods.pri,'Private class methods'],
1027
+ [methods.pri_inst,'Private instance methods']
1028
+ ].each do |meths, title|
1029
+ if meths && !meths.empty?
1030
+ grid_row{cell_label title, NFont, NColor, Black, :i=>HeaderInset}
1031
+ meths.sort.each do |name|
1032
+ grid_row{cell_label name, VFont, VColor, Black, :i=>LineInset}
1033
+ end
1034
+ end
1035
+ end
1036
+ end
1037
+
1038
+ def view
1039
+ @view ||= scroll_pane {
1040
+ val = @value
1041
+ grid_table{ #Body
1165
1042
  background :WHITE
1166
- title_section title
1167
- content_section
1168
- end
1169
- end
1043
+ opaque true
1044
+ defaults :a=>:nw, :wx=>0.1, :wy=>0.0, :f=>:h
1045
+
1046
+ title_section
1047
+
1048
+ header_section
1049
+
1050
+ ancestors_section
1051
+
1052
+ variables_section
1053
+
1054
+ methods_section
1055
+
1056
+ # FIXME: forcing stuff upwards; there *must* be a better way...
1057
+ grid_row{empty_cell(:a=>:se, :wy=>0.1, :f=>:v)}
1058
+ } #Body
1059
+ } # scroll_pane
1170
1060
  end
1171
1061
 
1172
- end
1062
+ end #GBLModuleViewer
1173
1063
 
1174
- class NavClassViewer < NavModuleViewer
1064
+ class GBLClassViewer < GBLModuleViewer
1175
1065
 
1176
1066
  def icon
1177
1067
  ClassIcon
1178
1068
  end
1179
1069
 
1180
- end
1070
+ def header_section
1071
+ val = @value
1072
+ superclazz = val.superclazz
1073
+ grid_row{ #Header
1074
+ grid_table {
1075
+ defaults :a=>:nw, :f=>:both, :wx=>0.0, :wy=>0.0, :i=>CellInset
1076
+ opaque false
1077
+ grid_row{
1078
+ cell_label 'Class', NFont, NColor, Black
1079
+ cell_label(val.qname.empty? ? val.value : val.qname, VFont, VColor, Black, :wx=>0.1)
1080
+ }
1081
+ grid_row{
1082
+ cell_label 'Id', NFont, NColor, Black
1083
+ cell_label(val.id.to_s, VFont, VColor, Black, :wx=>0.1)
1084
+ }
1085
+ grid_row{
1086
+ cell_label 'Superclass', NFont, NColor, Black
1087
+ cell_label(superclazz, VFont, VColor, Black, :wx=>0.1)
1088
+ } if superclazz
1089
+ }
1090
+ } #Header
1091
+ end
1092
+
1093
+ end #GBLClassViewer
1181
1094
 
1182
1095
 
1183
1096
  register_viewer(:root_node,nil,RootNodeViewer)
@@ -1188,13 +1101,10 @@ register_viewer(:env_java,nil,JavaEnvViewer)
1188
1101
  register_viewer(:global_vars,nil,GlobalVariablesViewer)
1189
1102
  register_viewer(:global_const,nil,ConstantsViewer)
1190
1103
  register_viewer(:config,nil,ConfigViewer)
1191
- #register_viewer(:object,nil,ObjectViewer)
1192
- register_viewer(:object,nil,NavObjectViewer)
1193
1104
  register_viewer(:constant,nil,ConstantViewer)
1194
- #register_viewer(Class,nil,ClassViewer)
1195
- #register_viewer(Module,nil,ModuleViewer)
1196
- register_viewer(Class,nil,NavClassViewer)
1197
- register_viewer(Module,nil,NavModuleViewer)
1105
+ register_viewer(:object,nil,GBLObjectViewer)
1106
+ register_viewer(Module,nil,GBLModuleViewer)
1107
+ register_viewer(Class,nil,GBLClassViewer)
1198
1108
  register_viewer(:results,nil,ResultListViewer)
1199
1109
 
1200
1110