limelight 0.5.1-java → 0.5.2-java

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 (37) hide show
  1. data/lib/limelight.jar +0 -0
  2. data/lib/limelight/builtin/utilities_production/alert/players/alert.rb +4 -1
  3. data/lib/limelight/builtin/utilities_production/production.rb +2 -2
  4. data/lib/limelight/dsl/styles_builder.rb +5 -0
  5. data/lib/limelight/java_couplings.rb +2 -2
  6. data/lib/limelight/main.rb +43 -46
  7. data/lib/limelight/producer.rb +21 -0
  8. data/lib/limelight/production.rb +18 -11
  9. data/lib/limelight/specs/test_scene_opener.rb +3 -0
  10. data/lib/limelight/stage.rb +62 -9
  11. data/lib/limelight/studio.rb +12 -143
  12. data/lib/limelight/styles/style.rb +288 -0
  13. data/lib/limelight/theater.rb +17 -2
  14. data/lib/limelight/version.rb +1 -1
  15. data/productions/examples/sandbox/stage_handles/players/sizer.rb +3 -0
  16. data/spec/limelight/builtin/players/combo_box_spec.rb +1 -1
  17. data/spec/limelight/builtin/players/radio_button_spec.rb +1 -1
  18. data/spec/limelight/casting_director_spec.rb +1 -1
  19. data/spec/limelight/commands/create_command_spec.rb +3 -3
  20. data/spec/limelight/commands/pack_command_spec.rb +1 -1
  21. data/spec/limelight/commands/unpack_command_spec.rb +1 -1
  22. data/spec/limelight/dsl/prop_builder_spec.rb +6 -6
  23. data/spec/limelight/file_chooser_spec.rb +1 -1
  24. data/spec/limelight/file_filter_spec.rb +2 -2
  25. data/spec/limelight/main_spec.rb +2 -2
  26. data/spec/limelight/paint_action_spec.rb +1 -1
  27. data/spec/limelight/pen_spec.rb +1 -1
  28. data/spec/limelight/producer_spec.rb +21 -8
  29. data/spec/limelight/production_spec.rb +4 -7
  30. data/spec/limelight/prop_spec.rb +2 -2
  31. data/spec/limelight/scene_spec.rb +1 -1
  32. data/spec/limelight/stage_spec.rb +32 -3
  33. data/spec/limelight/templates/templater_spec.rb +1 -1
  34. data/spec/limelight/theater_spec.rb +27 -0
  35. data/spec/spec_helper.rb +0 -6
  36. metadata +5 -4
  37. data/lib/limelight/styles.rb +0 -347
data/lib/limelight.jar CHANGED
Binary file
@@ -1,4 +1,7 @@
1
- module Alert
1
+ #- Copyright � 2008-2009 8th Light, Inc. All Rights Reserved.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ module Alert #:nodoc:
2
5
 
3
6
  prop_reader :message
4
7
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'monitor'
5
5
 
6
- module Production
6
+ module Production #:nodoc:
7
7
 
8
8
  def production_opening
9
9
  @monitor = Monitor.new
@@ -44,7 +44,7 @@ module Production
44
44
 
45
45
  def alert(message)
46
46
  @alert_monitor = @monitor.new_cond
47
- load_alert_scene(message)
47
+ load_alert_scene(message.to_s)
48
48
  @monitor.synchronize{ @alert_monitor.wait }
49
49
  @alert_stage.close
50
50
  return @alert_response
@@ -143,6 +143,11 @@ module Limelight
143
143
  raise StyleBuilderException.new("'#{sym}' is not a valid style") if !@__style.respond_to?(setter_sym)
144
144
  @__style.send(setter_sym, value.to_s)
145
145
  end
146
+
147
+ # Kernel.y was added by the yaml library in JRuby 1.4. Not sure what to do about this type of problem.
148
+ def y(*args) #:nodoc:
149
+ method_missing(:y, *args)
150
+ end
146
151
  end
147
152
 
148
153
  # Exception thrown by StyleBuilder when an error is encountered.
@@ -1,12 +1,12 @@
1
1
  #- Copyright � 2008-2009 8th Light, Inc. All Rights Reserved.
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
- module Limelight #:nodoc:
4
+ module Limelight
5
5
 
6
6
  Main = Java::limelight.Main
7
7
  ResourceLoader = Java::limelight.ResourceLoader
8
8
  Context = Java::limelight.Context
9
- Studio = Java::limelight.ui.api.Studio
9
+ Studio = Java::limelight.Studio
10
10
 
11
11
  module Background
12
12
  Animation = Java::limelight.background.Animation
@@ -5,31 +5,59 @@ require 'limelight/commands/command'
5
5
 
6
6
  module Limelight
7
7
 
8
- # Used to open and manage Limelight Productions.
8
+ # Limelight::Main is used, when installed as a gem, to work with Limelight production. It provides
9
+ # a handful of utilities to create, bundle, and develop with Limelight.
9
10
  #
10
- # Productions may have a single scene or multiple scenes.
11
+ # For example, running the following command will generate a new Limelight production for you.
11
12
  #
12
- # Single-Scene Production Directory Structure:
13
+ # jruby -S limelight create production <production name>
13
14
  #
14
- # - calculator
15
- # | - props.rb
16
- # | - styles.rb
17
- # | - players
18
- # | - <player_name>.rb
19
- # | - *
15
+ # Assuming you used "sandbox" as the name or your production, you'd end up with the following directory structure
16
+ # generated for you.
17
+ #
18
+ # - sandbox
20
19
  # | - stages.rb
20
+ # | - styles.rb
21
21
  # | - production.rb
22
+ # | - default_scene
23
+ # | - props.rb
24
+ # | - styles.rb
25
+ # | - players
26
+ # | - <player_name>.rb
27
+ # | - spec
28
+ # | - spec_helper.rb
29
+ # | - default_scene
30
+ # | - default_scene_spec.rb
22
31
  #
23
- # In a Single-Scene production, the scene name and production name are the same. As seen above, both names are 'calculator'.
24
- # Inside the scene there are three files and one directory, all of which are options.
32
+ # In this case, you've just created a production called "Sandbox". By convention, the name of the production matches the name of the root directory.
33
+ # Notice that there are 3 files and 2 directories. Let's start by talking about the files.
34
+ #
35
+ # == stages.rb
36
+ # This file uses a DSL to configure the stages that will be used in the production.
37
+ # See Limelight::StagesBuilder
38
+ #
39
+ # == styles.rb
40
+ # This file defines production level styles. Each scene may have their own styles but styles defined here will be avaiable to all scenes.
41
+ # See Limelight::StylesBuilder
42
+ #
43
+ # == production.rb
44
+ # This file defines a module names Production where you can defined hooks and behavior for your production.
45
+ # See Limelight::Production
46
+ #
47
+ # For the most part, each directory inside the root directory is a scene. This production has one scene named "default_scene" (this is the default name).
48
+ # Each scene starts out containing 2 file and a directory. Let's look at those..
25
49
  #
26
50
  # == props.rb
27
- # This file defines the props contained in the scene
51
+ # This file defines the structure of your scene. Scenes are composed of Props. In this file you use the Prop DSL to
52
+ # specify all the components of your scene.
28
53
  # See Limelight::PropBuilder
54
+ # See Limelight::Prop
29
55
  #
30
56
  # == styles.rb
31
- # This file defines the styles used in the scene
57
+ # Similar to the styles.rb file located in the root directory, this file contains definitions of styles. However,
58
+ # all styles defined here are only available to the containgin scene. Styles define the look and feel of your scenes.
32
59
  # See Limelight::StylesBuilder
60
+ # See Limelight::Style
33
61
  #
34
62
  # == players
35
63
  # A directory containing all the players used in the scene. Players are modules that are included by Prop objects.
@@ -37,40 +65,9 @@ module Limelight
37
65
  # Inside 'wall.rb' you would define a module named 'Wall'. All behavior defined in the Wall modules will automatically be included
38
66
  # in every prop named 'wall'.
39
67
  #
40
- # == stages.rb
41
- # This file uses a DSL to configure the stages that will be used in the production.
42
- # See Limelight::StagesBuilder
43
- #
44
- # == production.rb
45
- # This file uses a DSL to configure the current Production.
46
- # See Limelight::ProductionBuilder
47
- #
48
- # Multiple-Scene Production Directory Structure:
49
- #
50
- # - sandbox
51
- # | - stages.rb
52
- # | - production.rb
53
- # | - styles.rb
54
- # | - players
55
- # | - <player_name>.rb
56
- # | - fader
57
- # | - props.rb
58
- # | - styles.rb
59
- # | - players
60
- # | - <player_name>.rb
61
- # | - floater
62
- # | - props.rb
63
- # | - styles.rb
64
- # | - players
65
- # | - <player_name>.rb
66
- #
67
- # In a Multiple-Scene production, the production acquires that name of the root directory. In this case the production is named 'sandbox'.
68
- # Each directory inside the root directory is a scene. This production has two scenes named 'fader' and 'floater'. Each scene is structured
69
- # the same as in a Single-Scene production with the exception of the 'stages.rb' file. This file is specific to the production. The production
70
- # may contain a 'styles.rb' which contains styles used by multiple scenes. If some players are used in multiple Scenes, then it is useful to
71
- # to create a players directory in the Production root to hold the common players. Other files may exist in the directory structure and they will not
72
- # conflict with Limelight.
68
+ # So there's a brief overview for you. Besure to check out the Limelight Docs production. You can find it by installing Limelight and starting it up.
73
69
  #
70
+ # For more info on available commands:
74
71
  # See Limelight::Commands
75
72
  #
76
73
  class Main
@@ -170,6 +170,27 @@ module Limelight
170
170
  return extendable_styles.merge(new_styles)
171
171
  end
172
172
 
173
+ # Closes the specified production. The producer will trigger the hook, production_closing and production_closed,
174
+ # to keep the production aware of it's status. The Studio will also be informed of the closure. If no
175
+ # production remain opened, then the Limelight runtine will exit.
176
+ #
177
+ def close(production)
178
+ return if production.closed?
179
+ production.closed = true
180
+ return Thread.new do
181
+ begin
182
+ Thread.pass
183
+ production.production_closing
184
+ production.theater.close
185
+ production.production_closed
186
+ Context.instance.studio.production_closed(production)
187
+ rescue StandardError => e
188
+ puts e
189
+ puts e.backtrace
190
+ end
191
+ end
192
+ end
193
+
173
194
  def establish_production #:nodoc:
174
195
  @production.producer = self
175
196
  @production.theater = @theater
@@ -3,8 +3,10 @@
3
3
 
4
4
  require 'limelight/limelight_exception'
5
5
  require 'limelight/file_loader'
6
+ require 'limelight/dsl/styles_builder'
6
7
  require 'drb'
7
8
 
9
+
8
10
  module Limelight
9
11
 
10
12
  # The root object of Limelight Production. Every Prop in a production has access to its Production object.
@@ -26,6 +28,7 @@ module Limelight
26
28
 
27
29
  attr_reader :name, :root
28
30
  attr_accessor :producer, :theater
31
+ attr_accessor :closed #:nodoc:
29
32
 
30
33
 
31
34
  # Users typically need not create Production objects.
@@ -77,7 +80,7 @@ module Limelight
77
80
  def gems_directory
78
81
  return @root.path_to("__resources/gems/gems")
79
82
  end
80
-
83
+
81
84
  # Returns the path to the productions gems root
82
85
  #
83
86
  def gems_root
@@ -88,7 +91,7 @@ module Limelight
88
91
  #
89
92
  def scene_directory(name)
90
93
  return @root.root if name == :root
91
- return @root.path_to(name)
94
+ return @root.path_to(name)
92
95
  end
93
96
 
94
97
  # Returns the minimum version of limelight required to run this production. Default: "0.0.0"
@@ -137,22 +140,24 @@ module Limelight
137
140
  def production_closed
138
141
  end
139
142
 
143
+ # returns true if the production has been closed.
144
+ #
145
+ def closed?
146
+ return @closed
147
+ end
148
+
140
149
  # Closes the production. If there are no more productions open, the Limelight runtime will shutdown.
150
+ # The production will actually delegate to it's producer and the producer will close the production down.
141
151
  #
142
152
  def close
143
- return if @closed
144
- self.production_closing
145
- @theater.close
146
- @closed = true
147
- self.production_closed
148
- Context.instance.studio.production_closed(self)
153
+ @producer.close(self)
149
154
  end
150
155
 
151
156
  # Called when the last stage in this production's theater is closed. If the allow_close? returns true
152
157
  # this production will be closed.
153
158
  #
154
- def theater_empty!
155
- close if allow_close?
159
+ def theater_empty!
160
+ close if allow_close? && !closed?
156
161
  end
157
162
 
158
163
  # Returned the name of the default scene. This is only used when there are not stages defined in the production.
@@ -180,7 +185,9 @@ module Limelight
180
185
  alias :setName :name= #:nodoc:
181
186
  alias :allowClose :allow_close? #:nodoc:
182
187
 
183
- def callMethod(name, args) #:nodoc:
188
+ def callMethod(name, java_obj_array) #:nodoc:
189
+ args = []
190
+ java_obj_array.length.times { |i| args << java_obj_array[i] }
184
191
  send(name.to_sym, *args)
185
192
  end
186
193
 
@@ -1,3 +1,6 @@
1
+ #- Copyright � 2008-2009 8th Light, Inc. All Rights Reserved.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
1
4
  module Limelight
2
5
  module Specs
3
6
  module SpecHelper
@@ -199,15 +199,6 @@ module Limelight
199
199
  #
200
200
  def close
201
201
  @frame.close
202
- closed
203
- end
204
-
205
- # Invoked when the stage has been closed. Users need not call it.
206
- #
207
- def closed
208
- @current_scene.visible = false if @current_scene
209
- @current_scene = nil
210
- @theater.stage_closed(self)
211
202
  end
212
203
 
213
204
  # Loads a scene on the Stage. If the Stage is currently hosting a Scene, the original Scene will be removed and
@@ -261,6 +252,68 @@ module Limelight
261
252
  @current_scene = scene
262
253
  end
263
254
 
255
+ # returns true if the stage has been closed. Closed stages may not be reopened.
256
+ #
257
+ def closed?
258
+ return @frame.closed?
259
+ end
260
+
261
+ # Invoked when the stage is being closed.
262
+ # System hook that should NOT be called by you.
263
+ #
264
+ def closing(e)
265
+ end
266
+
267
+ # Invoked when the stage has been closed.
268
+ # System hook that should NOT be called by you.
269
+ #
270
+ def closed(e)
271
+ @current_scene.visible = false if @current_scene
272
+ @current_scene = nil
273
+ @theater.stage_closed(self)
274
+ end
275
+
276
+ # Invoked when the stage has gained focus on the desktop. Only 1 stage my have focus at a time.
277
+ # System hook that should NOT be called by you.
278
+ #
279
+ def focus_gained(e)
280
+ @theater.stage_activated(self)
281
+ end
282
+
283
+ # Invoked when the stage has lost focus on the desktop. Only 1 stage my have focus at a time.
284
+ # System hook that should NOT be called by you.
285
+ #
286
+ def focus_lost(e)
287
+ end
288
+
289
+ # Invoked when the stage has been iconified. This occurs when the stage is no longer visible on the desktop
290
+ # and an icon for the stage has been added to the OS's taskbar or dock.
291
+ # System hook that should NOT be called by you.
292
+ #
293
+ def iconified(e)
294
+ end
295
+
296
+ # Invoked when the stage has been deiconified. This occurs when the icon for the stage has been removed from the
297
+ # taskbar or dock, and the stage is again visible on the desktop.
298
+ # System hook that should NOT be called by you.
299
+ #
300
+ def deiconified(e)
301
+ end
302
+
303
+ # Invoked when the stage has become the active stage on the desktop. Only 1 stage my be active at a time.
304
+ # System hook that should NOT be called by you.
305
+ #
306
+ def activated(e)
307
+ @theater.stage_activated(self)
308
+ end
309
+
310
+ # Invoked when the stage has lost status as the active stage. Only 1 stage my have focus at a time.
311
+ # System hook that should NOT be called by you.
312
+ #
313
+ def deactivated(e)
314
+ @theater.stage_deactivated(self)
315
+ end
316
+
264
317
  protected #############################################
265
318
 
266
319
  def new_frame
@@ -1,185 +1,54 @@
1
1
  #- Copyright � 2008-2009 8th Light, Inc. All Rights Reserved.
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
-
4
- require 'limelight/producer'
3
+ raise "studio.rb is present for solely to document it's Java counterpart limelight.Studio. This file should NOT be loaded in the Ruby runtime."
5
4
 
6
5
  module Limelight
7
6
 
8
7
  # A Studio creates Productions. There is only one instance of Studio per Limelight runtime. All open productions
9
- # are opened by the studio.
8
+ # are opened and tracked by the studio.
10
9
  #
11
10
  class Studio
12
11
 
13
- class << self
14
-
15
- def install #:nodoc:
16
- Context.instance.studio = instance
17
- return instance
18
- end
19
-
20
- def instance #:nodoc:
21
- @studio = self.new if @studio.nil?
22
- return @studio
23
- end
24
-
25
- def reset #:nodoc:
26
- @studio = nil
27
- end
28
-
29
- end
30
-
31
- def index(production) #:nodoc:
32
- @index = [] if @index.nil?
33
- if name_taken?(production.name)
34
- assign_unique_name(production)
35
- elsif production.name.nil?
36
- assign_name_to(production)
37
- else
38
- error_if_duplicate_name(production.name)
39
- end
40
- @index << production
41
- end
42
-
43
- # Returns the production with the specified name that was previously opened but the Studio.
44
- #
45
- def [](name)
46
- return nil if @index.nil?
47
- return @index.find { |production| production.name == name }
48
- end
49
-
50
- def name_taken?(name) #:nodoc:
51
- return self[name] != nil
52
- end
53
-
54
- def error_if_duplicate_name(name) #:nodoc:
55
- raise Limelight::LimelightException.new("Production name '#{name}' is already taken") if name_taken?(name)
56
- end
57
-
58
12
  # Opens the production at the specified path.
59
13
  #
60
14
  def open(production_path)
61
- begin
62
- src = <<END
63
- #begin
64
- puts "$:: \#{$:.join(", ")}"
65
- puts "__FILE__: \#{__FILE__}"
66
- require 'limelight/limelight_init'
67
- require 'limelight/producer'
68
- producer = Limelight::Producer.new("#{production_path}")
69
- production = producer.production
70
- Java::java.lang.Thread.currentThread.handle = production
71
- producer.open
72
- #rescue Exception => e
73
- # raise e
74
- #end
75
- END
76
- production = Context.instance().runtimeFactory.spawn(src)
77
- index(production)
78
- return production
79
- rescue StandardError => e
80
- alert_and_shutdown(e)
81
- end
82
15
  end
83
16
 
84
- # def open(production_path)
85
- # begin
86
- # producer = Producer.new(production_path)
87
- # production = producer.production
88
- # index(production)
89
- # producer.open
90
- # return production
91
- # rescue StandardError => e
92
- # alert_and_shutdown(e)
93
- # end
94
- # end
17
+ # Returns the production with the specified name. If the studio never opened a production by that name, nil
18
+ # will be returned.
19
+ #
20
+ def get(name)
21
+ end
95
22
 
96
23
  # Returns true if all of the open productions allow closing.
97
24
  #
98
25
  def should_allow_shutdown
99
- return true if @index.nil?
100
- return @index.all? { |production| production.allow_close? }
101
26
  end
102
27
 
103
28
  # If allowed (should_allow_shutdown), this will close all open productions and shutdown the limelight runtime.
104
29
  #
105
30
  def shutdown
106
- return if @is_shutdown || @is_shutting_down
107
- return unless should_allow_shutdown
108
- @is_shutting_down = true
109
- @index.each { |production| production.close } if @index
110
- @utilities_production.close if @utilities_production
111
- @is_shutdown = true
112
- Thread.new { Context.instance().shutdown }
113
31
  end
114
32
 
115
- # Called when a production is closed to notify the studio of the event.
33
+ # Called when a production is closed to notify the studio of the event. Developers should not need to call this method.
116
34
  #
117
35
  def production_closed(production)
118
- puts "Studio.production_closed @index: #{@index}"
119
- if @index
120
- @index.delete(production)
121
- puts "closing production: #{production}"
122
- production.audit
123
- Context.instance().runtimeFactory.terminate(production)
124
- puts "index.inspect: #{@index.inspect}"
125
- end
126
- shutdown if @index && @index.empty?
127
36
  end
128
37
 
129
- # Returns an array of all the productions
38
+ # Returns a list of all the productions
130
39
  #
131
40
  def productions
132
- return @index.nil? ? [] : @index.dup
133
- end
134
-
135
- # Publish the Studio, using DRb, on the specified port.
136
- #
137
- def publish_on_drb(port)
138
- @drb_server = DRb.start_service("druby://0.0.0.0:#{port}", self)
139
41
  end
140
42
 
141
43
  # Returns the utilities production; a production used by limelight.
142
44
  #
143
45
  def utilities_production
144
- if @utilities_production == nil
145
- producer = Producer.new(File.join($LIMELIGHT_LIB, "limelight", "builtin", "utilities_production"))
146
- @utilities_production = producer.production
147
- producer.open
148
- end
149
- return @utilities_production
150
46
  end
151
47
 
152
- private #############################################
153
-
154
- def assign_unique_name(production) #:nodoc:
155
- count = 2
156
- name = production.name
157
- while name_taken?(name)
158
- name = "#{production.name}_#{count}"
159
- count += 1
160
- end
161
- production.name = name
162
- end
163
-
164
- def assign_name_to(production) #:nodoc:
165
- count = @index.length + 1
166
- while name_taken?(count.to_s)
167
- count += 1
168
- end
169
- production.name = count.to_s
170
- end
171
-
172
- def alert_and_shutdown(e)
173
- begin
174
- message = "#{e}\n#{e.backtrace.join("\n")}"
175
- utilities_production.alert(message)
176
- shutdown if @index.nil? || @index.empty?
177
- rescue Exception => e
178
- puts e
179
- puts e.backtrace
180
- end
48
+ # Returns true if the Studio has been shutdown. ie. The procees is exiting.
49
+ #
50
+ def shutdown?
181
51
  end
182
-
183
52
  end
184
53
 
185
54
  end