cheri 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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,446 @@
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
+ # TODO: module comments
28
+
29
+ module Swing
30
+ VERSION = Cheri::VERSION
31
+
32
+ CJava = Cheri::Java #:nodoc:
33
+ CBuilder = Cheri::Builder #:nodoc:
34
+ JBuilder = Cheri::Java::Builder #:nodoc:
35
+ AWT = Cheri::AWT #:nodoc:
36
+ AWTFrame = Cheri::AWT::AWTFrame #:nodoc:
37
+ AWTProxy = Cheri::AWT::AWTProxy #:nodoc:
38
+ JComp = javax.swing.JComponent #:nodoc:
39
+ RPC = javax.swing.RootPaneContainer #:nodoc:
40
+ # types checked by cherify/cheri_yield logic
41
+ # TODO: more
42
+ SwingTypes = [
43
+ javax.swing.Action,
44
+ javax.swing.JComponent,
45
+ javax.swing.RootPaneContainer,
46
+ javax.swing.border.Border
47
+ ]
48
+ SwingPkg = 'javax.swing.'
49
+
50
+ class << self
51
+ def append_features(clazz)
52
+ CBuilder.module_included(Cheri::AWT,clazz)
53
+ CBuilder.module_included(JBuilder,clazz)
54
+ CBuilder.module_included(self,clazz)
55
+ super
56
+ end
57
+ private :append_features
58
+
59
+ def factory
60
+ SwingFactory
61
+ end
62
+
63
+ def connecter
64
+ SwingConnecter
65
+ end
66
+
67
+ def consumer
68
+ SwingConsumer
69
+ end
70
+
71
+ def resolver
72
+ SwingResolver
73
+ end
74
+
75
+ # a bit expensive, but only used by cherify/cheri_yield
76
+ def swing?(obj)
77
+ obj.respond_to?(:java_class) &&
78
+ (obj.java_class.name.rindex(SwingPkg,0) ||
79
+ !(obj.class.ancestors & SwingTypes).empty?)
80
+ end
81
+ end #self
82
+
83
+ # call-seq:
84
+ # awt([*args] [, &block]) -> AWTProxy if no block given, else result of block
85
+ #
86
+ #--
87
+ # Duplicating this here rather than including Cheri::AWT. (See note re: performance)
88
+ #++
89
+ def awt(*r,&k)
90
+ if (ctx = __cheri_ctx)
91
+ if k
92
+ AWTFrame.new(ctx,*r,&k).run
93
+ else
94
+ ctx[:awt_proxy] ||= AWTProxy.new(ctx,*r)
95
+ end
96
+ end
97
+ end
98
+ private :awt
99
+
100
+ # call-seq:
101
+ # swing([*args] [, &block]) -> SwingProxy if no block given, else result of block
102
+ #
103
+ def swing(*r,&k)
104
+ if (ctx = __cheri_ctx)
105
+ if k
106
+ if ctx.empty? && (c = ctx.client).kind_of?(RPC) || c.kind_of?(JComp)
107
+ ctx.fsend(CheriYieldFactory,:cheri_yield,c,&k)
108
+ else
109
+ SwingFrame.new(ctx,*r,&k).run
110
+ end
111
+ else
112
+ ctx[:swing_proxy] ||= SwingProxy.new(ctx,*r)
113
+ end
114
+ end
115
+ end
116
+ private :swing
117
+
118
+ AnyTypes = {
119
+ javax.swing.ButtonGroup => true
120
+ }
121
+
122
+ class BaseBuilder < Cheri::Java::Builder::BaseBuilder
123
+ JF = CJava.get_class('javax.swing.JFrame')
124
+
125
+ def mod
126
+ Cheri::Swing
127
+ end
128
+
129
+ def any?
130
+ @any
131
+ end
132
+
133
+ private
134
+ def post
135
+ @obj.icon_image ||= CJava.cheri_icon.image if @obj.kind_of?(JF)
136
+ if AnyTypes[@clazz]
137
+ @any = true
138
+ @not_parent = true
139
+ @not_child = true
140
+ end
141
+ end
142
+ end #BaseBuilder
143
+
144
+ class ClassBuilder < BaseBuilder
145
+ def initialize(ctx,sym,clazz,*args,&block)
146
+ super(ctx,sym,*args,&block)
147
+ @clazz = clazz
148
+ @resolve = true
149
+ end
150
+ private
151
+ def create
152
+ @obj = @clazz.new(*@args)
153
+ end
154
+ end #ClassBuilder
155
+
156
+ class ProcBuilder < BaseBuilder
157
+ def initialize(ctx,sym,proc,*args,&block)
158
+ super(ctx,sym,*args,&block)
159
+ @proc = proc
160
+ end
161
+ private
162
+ def create
163
+ @obj = @proc.call(*@args)
164
+ @clazz = @obj.class
165
+ @resolve = true
166
+ end
167
+ end #ProcBuilder
168
+
169
+ class CherifyBuilder < BaseBuilder
170
+ def initialize(ctx,sym,obj,*args,&block)
171
+ super(ctx,sym,*args,&block)
172
+ @obj = obj
173
+ @clazz = obj.class
174
+ @no_create = true
175
+ @resolve = true
176
+ end
177
+ end #CherifyBuilder
178
+
179
+ class CheriYieldBuilder < BaseBuilder
180
+ def initialize(ctx,sym,obj,*args,&block)
181
+ super(ctx,sym,*args,&block)
182
+ @obj = obj
183
+ @clazz = obj.class
184
+ @no_create = true
185
+ @not_child = true
186
+ @resolve = true
187
+ end
188
+ end #CheriYieldBuilder
189
+
190
+ # TODO: comments
191
+ module CherifyFactory
192
+ S = ::Cheri::Swing #:nodoc:
193
+ def self.builder(ctx,sym,*args,&block)
194
+ return nil unless sym == :cherify && !args.empty? && S.swing?(args[0])
195
+ raise Cheri.argument_error(args.length,1..2) unless args.length == 1 || args.length == 2
196
+ CherifyBuilder.new(ctx,sym,*args,&block)
197
+ end
198
+ end #CherifyFactory
199
+
200
+ # TODO: comments
201
+ module CheriYieldFactory # < Cheri::AbstractFactory
202
+ S = ::Cheri::Swing #:nodoc:
203
+ def self.builder(ctx,sym,*args,&block)
204
+ return nil unless sym == :cheri_yield && !args.empty? && S.swing?(args[0])
205
+ raise Cheri.argument_error(args.length,1) unless args.length == 1
206
+ CheriYieldBuilder.new(ctx,sym,*args,&block)
207
+ end
208
+ end #CheriYieldFactory
209
+
210
+ # TODO: comments
211
+ module StandardFactory
212
+ def self.builder(ctx,sym,*args,&block)
213
+ clazz = Types.get_class(sym)
214
+ clazz ? ClassBuilder.new(ctx,sym,clazz,*args,&block) : nil
215
+ end
216
+ end #StandardFactory
217
+
218
+ module BoxComponentFactory
219
+ CJava = Cheri::Java
220
+ X_AXIS = 0
221
+ Y_AXIS = 1
222
+ LINE_AXIS = 2
223
+ PAGE_AXIS = 3
224
+ RPC = javax.swing.RootPaneContainer
225
+ @box = nil
226
+ @box_layout = nil
227
+ @panel = nil
228
+ @dimension = nil
229
+ @procs = {}
230
+ class << self
231
+ def builder(ctx,sym,*args,&block)
232
+ proc = @procs[sym]
233
+ proc ? ProcBuilder.new(ctx,sym,proc,*args,&block) : nil
234
+ end
235
+ def box
236
+ @box ||= CJava.get_class('javax.swing.Box')
237
+ end
238
+ def box_layout
239
+ @box_layout ||= CJava.get_class('javax.swing.BoxLayout')
240
+ end
241
+ def panel
242
+ @panel ||= CJava.get_class('javax.swing.JPanel')
243
+ end
244
+ def dimension
245
+ @dimension ||= CJava.get_class('java.awt.Dimension')
246
+ end
247
+ def names
248
+ @names ||= @procs.keys
249
+ end
250
+ end #self
251
+
252
+ @procs[:box_layout] =
253
+ Proc.new do |obj,axis|
254
+ iaxis = case axis
255
+ when :X_AXIS : X_AXIS
256
+ when :Y_AXIS : Y_AXIS
257
+ when :LINE_AXIS : LINE_AXIS
258
+ when :PAGE_AXIS : PAGE_AXIS
259
+ else axis
260
+ end
261
+ box_layout.new(obj.kind_of?(RPC) ? obj.content_pane : obj,iaxis)
262
+ end
263
+ @procs[:x_box] = @procs[:h_box] = @procs[:horizontal_box] = Proc.new { box.new(X_AXIS) }
264
+ @procs[:y_box] = @procs[:v_box] = @procs[:vertical_box] = Proc.new { box.new(Y_AXIS) }
265
+ @procs[:line_box] = Proc.new { box.new(LINE_AXIS) }
266
+ @procs[:page_box] = Proc.new { box.new(PAGE_AXIS) }
267
+ @procs[:x_panel] = @procs[:h_panel] = @procs[:horizontal_panel] =
268
+ Proc.new do |*args|
269
+ p = panel.new(*args)
270
+ p.setLayout(box_layout.new(p,X_AXIS))
271
+ p
272
+ end
273
+ @procs[:y_panel] = @procs[:v_panel] = @procs[:vertical_panel] =
274
+ Proc.new do |*args|
275
+ p = panel.new(*args)
276
+ p.setLayout(box_layout.new(p,Y_AXIS))
277
+ p
278
+ end
279
+ @procs[:line_panel] =
280
+ Proc.new do |*args|
281
+ p = panel.new(*args)
282
+ p.setLayout(box_layout.new(p,LINE_AXIS))
283
+ p
284
+ end
285
+ @procs[:page_panel] =
286
+ Proc.new do |*args|
287
+ p = panel.new(*args)
288
+ p.setLayout(box_layout.new(p,PAGE_AXIS))
289
+ p
290
+ end
291
+ @procs[:glue] = Proc.new { box.createGlue }
292
+ @procs[:x_glue] = @procs[:h_glue] = @procs[:horizontal_glue] = Proc.new { box.createHorizontalGlue }
293
+ @procs[:y_glue] = @procs[:v_glue] = @procs[:vertical_glue] = Proc.new { box.createVerticalGlue }
294
+ @procs[:x_strut] = @procs[:h_strut] = @procs[:horizontal_strut] =
295
+ Proc.new do |*args|
296
+ box.createHorizontalStrut(*args)
297
+ end
298
+ @procs[:y_strut] = @procs[:v_strut] = @procs[:vertical_strut] =
299
+ Proc.new do |*args|
300
+ box.createVerticalStrut(*args)
301
+ end
302
+ @procs[:rigid_area] = @procs[:spacer] =
303
+ Proc.new do |*args|
304
+ box.createRigidArea(dimension.new(*args))
305
+ end
306
+ @procs[:x_spacer] = @procs[:h_spacer] = @procs[:horizontal_spacer] =
307
+ Proc.new do |*args|
308
+ box.createRigidArea(dimension.new(args[0],0))
309
+ end
310
+ @procs[:y_spacer] = @procs[:v_spacer] = @procs[:vertical_spacer] =
311
+ Proc.new do |*args|
312
+ box.createRigidArea(dimension.new(0,args[0]))
313
+ end
314
+ @procs[:filler] =
315
+ Proc.new do |*args|
316
+ box::Filler.new(dimension.new(args[0],args[1]),
317
+ dimension.new(args[2],args[3]),
318
+ dimension.new(args[4],args[5]))
319
+ end
320
+ end #BoxComponentFactory
321
+
322
+
323
+ # TODO: more factories
324
+
325
+ module DialogComponentFactory
326
+ CJava = Cheri::Java
327
+
328
+ end #DialogComponentFactory
329
+
330
+
331
+ SwingFactory = Cheri::Builder::SuperFactory.new do |f|
332
+ f << StandardFactory
333
+ f << BoxComponentFactory
334
+ f << Cheri::AWT::StandardFactory
335
+ f << CheriYieldFactory
336
+ f << CherifyFactory
337
+ f << Cheri::Java::Builder::CheriYieldFactory
338
+ f << Cheri::Java::Builder::CherifyFactory
339
+ f << Cheri::Builder::CheriYieldFactory
340
+ f << Cheri::Builder::CherifyFactory
341
+ end
342
+
343
+ class SwingProxy < Cheri::AWT::AWTProxy
344
+
345
+ impl(Types.names)
346
+ impl(BoxComponentFactory.names)
347
+
348
+ def initialize(ctx,*r)
349
+ super
350
+ if Hash === r.last
351
+ @ctx.auto!(mod) if r.last[:auto]
352
+ end
353
+ end
354
+
355
+ def mod
356
+ Cheri::Swing
357
+ end
358
+ private :mod
359
+
360
+ def [](opts)
361
+ raise Cheri.type_error(opts,Hash,Symbol) unless Hash === opts || Symbol === opts
362
+ if opts == :auto || (Hash === opts && opts[:auto])
363
+ @ctx.ictx.auto!(mod)
364
+ @ctx.auto!(mod)
365
+ # if (c = @ctx.client).kind_of?(RPC) || c.kind_of?(JComp)
366
+ # @ctx.push(b = CheriYieldBuilder.new(@ctx,:cheri_yield,c))
367
+ # b.run
368
+ # else
369
+ # @ctx.push(SwingFrame.new(@ctx))
370
+ # end
371
+ end
372
+ nil
373
+ end
374
+ end #SwingProxy
375
+
376
+ class SwingFrame
377
+ include Cheri::Builder::Frame
378
+ def initialize(ctx,*r,&k)
379
+ super
380
+ @obj = ctx[:swing_proxy] ||= SwingProxy.new(ctx,*r)
381
+ end
382
+
383
+ def mod
384
+ Cheri::Swing
385
+ end
386
+ end #SwingFrame
387
+
388
+ SwingResolver = Cheri::Java::Builder::ConstantResolver.new do |r|
389
+ r << Cheri::AWT::Constants
390
+ r << Constants
391
+ end
392
+
393
+ module AlignMethodConsumer
394
+ BOTTOM = 1.0
395
+ CENTER = 0.5
396
+ LEFT = 0.0
397
+ RIGHT = 1.0
398
+ TOP = 0.0
399
+ JComp = javax.swing.JComponent
400
+
401
+ def self.consume(ctx,bld,sym,*args,&k)
402
+ return false,nil unless sym == :align && (obj = bld.object).kind_of?(JComp)
403
+ argc = args.length
404
+ raise Cheri.new_argument_error(argc,1..2) unless argc == 1 || argc == 2
405
+ x_val = nil
406
+ y_val = nil
407
+ 0.upto(argc-1) do |i|
408
+ arg = args[i]
409
+ if arg.kind_of?(Numeric)
410
+ unless argc == 2
411
+ raise ArgumentError,"align can't evaluate numeric value with only one argument -- specify both x and y"
412
+ end
413
+ i == 0 ? x_val = arg : y_val = arg
414
+ else
415
+ raise ArgumentError,"invalid argument for align: #{arg}" unless arg.instance_of?(Symbol)
416
+ case arg
417
+ when :TOP : y_val = TOP
418
+ when :BOTTOM : y_val = BOTTOM
419
+ when :LEFT : x_val = LEFT
420
+ when :RIGHT : x_val = RIGHT
421
+ when :CENTER :
422
+ if argc ==2
423
+ i == 0 ? x_val = CENTER : y_val = CENTER
424
+ else
425
+ x_val = y_val = CENTER
426
+ end
427
+ else raise ArgumentError,"invalid argument for align: #{arg}"
428
+ end
429
+ end
430
+ end
431
+ obj.alignment_x = x_val if x_val
432
+ obj.alignment_y = y_val if y_val
433
+ return true,nil
434
+ end
435
+ end #AlignMethodConsumer
436
+
437
+ SwingConsumer = Cheri::Builder::SuperConsumer.new do |c|
438
+ c << AlignMethodConsumer
439
+ c << Cheri::AWT::SizeMethodConsumer
440
+ c << Cheri::Java::Builder::EventMethodConsumer
441
+ c << Cheri::Java::Builder::GenericConsumer
442
+ c << Cheri::Builder::DefaultConsumer
443
+ end
444
+
445
+ end #Swing
446
+ end #Cheri
@@ -0,0 +1,270 @@
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 Swing
27
+ module Types
28
+ CJava = Cheri::Java #:nodoc:
29
+ JS = 'javax.swing.'.freeze #:nodoc:
30
+ class << self
31
+ def get_class(sym)
32
+ # TODO: threadsafe support?
33
+ cls = @classes[sym]
34
+ if cls
35
+ if cls.instance_of?(String)
36
+ cls = CJava.get_class(JS + cls)
37
+ @classes[sym] = cls if cls
38
+ end
39
+ cls
40
+ else
41
+ nil
42
+ end
43
+ end
44
+ def names
45
+ @names ||= @classes.keys
46
+ end
47
+ end #self
48
+ # TODO: review included classes; some of these would
49
+ # never be called in a builder context
50
+ @classes = {
51
+ :action_map => 'ActionMap',
52
+ :border_factory => 'BorderFactory',
53
+ :box => 'Box',
54
+ # handling box_layout in BoxComponentFactory to simplify syntax
55
+ # :box_layout => 'BoxLayout',
56
+ :button_group => 'ButtonGroup',
57
+ :cell_renderer_pane => 'CellRendererPane',
58
+ :component_input_map => 'ComponentInputMap',
59
+ :default_bounded_range_model => 'DefaultBoundedRangeModel',
60
+ :default_button_model => 'DefaultButtonModel',
61
+ :default_cell_editor => 'DefaultCellEditor',
62
+ :default_combo_box_model => 'DefaultComboBoxModel',
63
+ :default_desktop_manager => 'DefaultDesktopManager',
64
+ :default_focus_manager => 'DefaultFocusManager',
65
+ :default_list_cell_renderer => 'DefaultListCellRenderer',
66
+ :default_list_cell_renderer_ui_resource => 'DefaultListCellRenderer::UIResource',
67
+ :default_list_model => 'DefaultListModel',
68
+ :default_list_selection_model => 'DefaultListSelectionModel',
69
+ :default_row_sorter => 'DefaultRowSorter',
70
+ :default_row_sorter_model_wrapper => 'DefaultRowSorter::ModelWrapper',
71
+ :default_single_selection_model => 'DefaultSingleSelectionModel',
72
+ :focus_manager => 'FocusManager',
73
+ :gray_filter => 'GrayFilter',
74
+ :group_layout => 'GroupLayout',
75
+ :image_icon => 'ImageIcon',
76
+ :input_map => 'InputMap',
77
+ :input_verifier => 'InputVerifier',
78
+ :internal_frame_focus_traversal_policy => 'InternalFrameFocusTraversalPolicy',
79
+ :j_applet => 'JApplet',
80
+ :applet => 'JApplet',
81
+ :j_button => 'JButton',
82
+ :button => 'JButton',
83
+ :j_check_box => 'JCheckBox',
84
+ :check_box => 'JCheckBox',
85
+ :j_check_box_menu_item => 'JCheckBoxMenuItem',
86
+ :check_box_menu_item => 'JCheckBoxMenuItem',
87
+ :j_color_chooser => 'JColorChooser',
88
+ :color_chooser => 'JColorChooser',
89
+ :j_combo_box => 'JComboBox',
90
+ :combo_box => 'JComboBox',
91
+ :j_component => 'JComponent',
92
+ :component => 'JComponent',
93
+ :j_desktop_pane => 'JDesktopPane',
94
+ :desktop_pane => 'JDesktopPane',
95
+ :j_dialog => 'JDialog',
96
+ :dialog => 'JDialog',
97
+ :j_editor_pane => 'JEditorPane',
98
+ :editor_pane => 'JEditorPane',
99
+ :j_file_chooser => 'JFileChooser',
100
+ :file_chooser => 'JFileChooser',
101
+ :j_formatted_text_field => 'JFormattedTextField',
102
+ :formatted_text_field => 'JFormattedTextField',
103
+ :j_frame => 'JFrame',
104
+ :frame => 'JFrame',
105
+ :j_internal_frame => 'JInternalFrame',
106
+ :internal_frame => 'JInternalFrame',
107
+ :j_internal_frame_desktop_icon => 'JInternalFrame::JDesktopIcon',
108
+ :internal_frame_desktop_icon => 'JInternalFrame::JDesktopIcon',
109
+ :j_label => 'JLabel',
110
+ :label => 'JLabel',
111
+ :j_layered_pane => 'JLayeredPane',
112
+ :layered_pane => 'JLayeredPane',
113
+ :j_list => 'JList',
114
+ :list => 'JList',
115
+ :j_list_drop_location => 'JList::DropLocation',
116
+ :list_drop_location => 'JList::DropLocation',
117
+ :j_menu => 'JMenu',
118
+ :menu => 'JMenu',
119
+ :j_menu_bar => 'JMenuBar',
120
+ :menu_bar => 'JMenuBar',
121
+ :j_menu_item => 'JMenuItem',
122
+ :menu_item => 'JMenuItem',
123
+ :j_option_pane => 'JOptionPane',
124
+ :option_pane => 'JOptionPane',
125
+ :j_panel => 'JPanel',
126
+ :panel => 'JPanel',
127
+ :j_password_field => 'JPasswordField',
128
+ :password_field => 'JPasswordField',
129
+ :j_popup_menu => 'JPopupMenu',
130
+ :popup_menu => 'JPopupMenu',
131
+ :j_popup_menu_separator => 'JPopupMenu::Separator',
132
+ :popup_menu_separator => 'JPopupMenu::Separator',
133
+ :j_progress_bar => 'JProgressBar',
134
+ :progress_bar => 'JProgressBar',
135
+ :j_radio_button => 'JRadioButton',
136
+ :radio_button => 'JRadioButton',
137
+ :j_radio_button_menu_item => 'JRadioButtonMenuItem',
138
+ :radio_button_menu_item => 'JRadioButtonMenuItem',
139
+ :j_root_pane => 'JRootPane',
140
+ :root_pane => 'JRootPane',
141
+ :j_scroll_bar => 'JScrollBar',
142
+ :scroll_bar => 'JScrollBar',
143
+ :j_scroll_pane => 'JScrollPane',
144
+ :scroll_pane => 'JScrollPane',
145
+ :j_separator => 'JSeparator',
146
+ :separator => 'JSeparator',
147
+ :j_slider => 'JSlider',
148
+ :slider => 'JSlider',
149
+ :j_spinner => 'JSpinner',
150
+ :spinner => 'JSpinner',
151
+ :j_spinner_date_editor => 'JSpinner::DateEditor',
152
+ :spinner_date_editor => 'JSpinner::DateEditor',
153
+ :j_spinner_default_editor => 'JSpinner::DefaultEditor',
154
+ :spinner_default_editor => 'JSpinner::DefaultEditor',
155
+ :j_spinner_list_editor => 'JSpinner::ListEditor',
156
+ :spinner_list_editor => 'JSpinner::ListEditor',
157
+ :j_spinner_number_editor => 'JSpinner::NumberEditor',
158
+ :spinner_number_editor => 'JSpinner::NumberEditor',
159
+ :j_split_pane => 'JSplitPane',
160
+ :split_pane => 'JSplitPane',
161
+ :j_tabbed_pane => 'JTabbedPane',
162
+ :tabbed_pane => 'JTabbedPane',
163
+ :j_table => 'JTable',
164
+ :table => 'JTable',
165
+ :j_table_drop_location => 'JTable::DropLocation',
166
+ :table_drop_location => 'JTable::DropLocation',
167
+ :j_text_area => 'JTextArea',
168
+ :text_area => 'JTextArea',
169
+ :j_text_field => 'JTextField',
170
+ :text_field => 'JTextField',
171
+ :j_text_pane => 'JTextPane',
172
+ :text_pane => 'JTextPane',
173
+ :j_toggle_button => 'JToggleButton',
174
+ :toggle_button => 'JToggleButton',
175
+ :j_toggle_button_toggle_button_model => 'JToggleButton::ToggleButtonModel',
176
+ :toggle_button_toggle_button_model => 'JToggleButton::ToggleButtonModel',
177
+ :toggle_button_model => 'JToggleButton::ToggleButtonModel',
178
+ :j_tool_bar => 'JToolBar',
179
+ :tool_bar => 'JToolBar',
180
+ :j_tool_bar_separator => 'JToolBar::Separator',
181
+ :tool_bar_separator => 'JToolBar::Separator',
182
+ :j_tool_tip => 'JToolTip',
183
+ :tool_tip => 'JToolTip',
184
+ :j_tree => 'JTree',
185
+ :tree => 'JTree',
186
+ :j_tree_drop_location => 'JTree::DropLocation',
187
+ :tree_drop_location => 'JTree::DropLocation',
188
+ :j_tree_dynamic_util_tree_node => 'JTree::DynamicUtilTreeNode',
189
+ :tree_dynamic_util_tree_node => 'JTree::DynamicUtilTreeNode',
190
+ :dynamic_util_tree_node => 'JTree::DynamicUtilTreeNode',
191
+ :j_tree_empty_selection_model => 'JTree::EmptySelectionModel',
192
+ :tree_empty_selection_model => 'JTree::EmptySelectionModel',
193
+ :j_viewport => 'JViewport',
194
+ :viewport => 'JViewport',
195
+ :j_window => 'JWindow',
196
+ :window => 'JWindow',
197
+ :key_stroke => 'KeyStroke',
198
+ :layout_focus_traversal_policy => 'LayoutFocusTraversalPolicy',
199
+ :layout_style => 'LayoutStyle',
200
+ :look_and_feel => 'LookAndFeel',
201
+ :menu_selection_manager => 'MenuSelectionManager',
202
+ :overlay_layout => 'OverlayLayout',
203
+ :popup => 'Popup',
204
+ :popup_factory => 'PopupFactory',
205
+ :progress_monitor => 'ProgressMonitor',
206
+ :progress_monitor_input_stream => 'ProgressMonitorInputStream',
207
+ :repaint_manager => 'RepaintManager',
208
+ :row_filter => 'RowFilter',
209
+ :row_filter_entry => 'RowFilter::Entry ',
210
+ :row_sorter => 'RowSorter',
211
+ :row_sorter_sort_key => 'RowSorter::SortKey',
212
+ :scroll_pane_layout => 'ScrollPaneLayout',
213
+ :scroll_pane_layout_ui_resource => 'ScrollPaneLayout::UIResource',
214
+ :size_requirements => 'SizeRequirements',
215
+ :size_sequence => 'SizeSequence',
216
+ :sorting_focus_traversal_policy => 'SortingFocusTraversalPolicy',
217
+ :spinner_date_model => 'SpinnerDateModel',
218
+ :spinner_list_model => 'SpinnerListModel',
219
+ :spinner_number_model => 'SpinnerNumberModel',
220
+ :spring => 'Spring',
221
+ :spring_layout => 'SpringLayout',
222
+ :spring_layout_constraints => 'SpringLayout::Constraints',
223
+ :swing_utilities => 'SwingUtilities',
224
+ :swing_worker => 'SwingWorker',
225
+ :timer => 'Timer',
226
+ :tool_tip_manager => 'ToolTipManager',
227
+ :transfer_handler => 'TransferHandler',
228
+ :transfer_handler_drop_location => 'TransferHandler::DropLocation',
229
+ :transfer_handler_transfer_support => 'TransferHandler::TransferSupport',
230
+ :ui_defaults => 'UIDefaults',
231
+ :ui_defaults_lazy_input_map => 'UIDefaults::LazyInputMap',
232
+ :ui_defaults_proxy_lazy_value => 'UIDefaults::ProxyLazyValue',
233
+ :ui_manager => 'UIManager',
234
+ :ui_manager_look_and_feel_info => 'UIManager::LookAndFeelInfo',
235
+ :viewport_layout => 'ViewportLayout',
236
+ :bevel_border => 'border.BevelBorder',
237
+ :compound_border => 'border.CompoundBorder',
238
+ :empty_border => 'border.EmptyBorder',
239
+ :etched_border => 'border.EtchedBorder',
240
+ :line_border => 'border.LineBorder',
241
+ :matte_border => 'border.MatteBorder',
242
+ :soft_bevel_border => 'border.SoftBevelBorder',
243
+ :titled_border => 'border.TitledBorder',
244
+ :color_chooser_component_factory => 'colorchooser.ColorChooserComponentFactory',
245
+ :default_color_selection_model => 'colorchooser.DefaultColorSelectionModel',
246
+ :file_name_extension_filter => 'filechooser.FileNameExtensionFilter',
247
+ :default_table_cell_renderer => 'table.DefaultTableCellRenderer',
248
+ :default_table_cell_renderer_ui_resource => 'table.DefaultTableCellRenderer::UIResource',
249
+ :default_table_column_model => 'table.DefaultTableColumnModel',
250
+ :default_table_model => 'table.DefaultTableModel',
251
+ :j_table_header => 'table.JTableHeader',
252
+ :table_header => 'table.JTableHeader',
253
+ :table_column => 'table.TableColumn',
254
+ :table_row_sorter => 'table.TableRowSorter',
255
+ :default_mutable_tree_node => 'tree.DefaultMutableTreeNode',
256
+ :default_tree_cell_editor => 'tree.DefaultTreeCellEditor',
257
+ :default_tree_cell_renderer => 'tree.DefaultTreeCellRenderer',
258
+ :default_tree_model => 'tree.DefaultTreeModel',
259
+ :default_tree_selection_model => 'tree.DefaultTreeSelectionModel',
260
+ :fixed_height_layout_cache => 'tree.FixedHeightLayoutCache',
261
+ :tree_path => 'tree.TreePath',
262
+ :variable_height_layout_cache => 'tree.VariableHeightLayoutCache'
263
+ }
264
+
265
+ end #StandardTypes
266
+ end #Swing
267
+ end #Cheri
268
+
269
+ #cls = Cheri::Swing::StandardTypes.get_class(:frame)
270
+ #puts cls.java_class.name