glimmer-dsl-swt 4.18.7.7 → 4.19.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/README.md +18 -8
  4. data/RUBY_VERSION +1 -1
  5. data/VERSION +1 -1
  6. data/bin/girb +10 -9
  7. data/bin/girb_runner.rb +8 -3
  8. data/bin/glimmer +10 -1
  9. data/bin/glimmer-setup +58 -0
  10. data/bin/glimmer_runner.rb +4 -0
  11. data/docs/reference/GLIMMER_COMMAND.md +19 -30
  12. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +6 -2
  13. data/docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md +7 -1
  14. data/docs/reference/GLIMMER_SAMPLES.md +25 -0
  15. data/glimmer-dsl-swt.gemspec +0 -0
  16. data/lib/glimmer-dsl-swt.rb +8 -0
  17. data/lib/glimmer/dsl/swt/c_tab_item_expression.rb +58 -0
  18. data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +2 -1
  19. data/lib/glimmer/dsl/swt/tab_item_expression.rb +7 -3
  20. data/lib/glimmer/dsl/swt/widget_expression.rb +1 -1
  21. data/lib/glimmer/launcher.rb +27 -51
  22. data/lib/glimmer/rake_task.rb +1 -1
  23. data/lib/glimmer/rake_task/package.rb +7 -2
  24. data/lib/glimmer/rake_task/scaffold.rb +227 -254
  25. data/lib/glimmer/swt/c_tab_item_proxy.rb +53 -0
  26. data/lib/glimmer/swt/custom/shape.rb +15 -1
  27. data/lib/glimmer/swt/sash_form_proxy.rb +6 -0
  28. data/lib/glimmer/swt/shell_proxy.rb +3 -1
  29. data/lib/glimmer/swt/tab_folder_proxy.rb +1 -0
  30. data/lib/glimmer/swt/tab_item_proxy.rb +17 -18
  31. data/lib/glimmer/swt/widget_proxy.rb +9 -0
  32. data/samples/elaborate/mandelbrot_fractal.rb +1 -1
  33. data/samples/hello/hello_c_combo.rb +68 -0
  34. data/samples/hello/hello_c_tab.rb +271 -0
  35. data/samples/hello/hello_tab.rb +2 -0
  36. data/vendor/swt/linux/swt.jar +0 -0
  37. data/vendor/swt/mac/swt.jar +0 -0
  38. data/vendor/swt/windows/swt.jar +0 -0
  39. metadata +41 -11
Binary file
@@ -42,3 +42,11 @@ require 'facets/hash/symbolize_keys'
42
42
  require 'ext/glimmer/config'
43
43
  require 'ext/glimmer'
44
44
  require 'glimmer/dsl/swt/dsl'
45
+
46
+ if defined?(::IRB)
47
+ begin
48
+ Kernel.send(:remove_method, :y)
49
+ rescue
50
+ # No Op
51
+ end
52
+ end
@@ -0,0 +1,58 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer'
23
+ require 'glimmer/dsl/static_expression'
24
+ require 'glimmer/dsl/parent_expression'
25
+ require 'glimmer/swt/widget_proxy'
26
+ require 'glimmer/swt/c_tab_item_proxy'
27
+
28
+ module Glimmer
29
+ module DSL
30
+ module SWT
31
+ class CTabItemExpression < StaticExpression
32
+ include ParentExpression
33
+
34
+ include_package 'org.eclipse.swt.custom'
35
+
36
+ def can_interpret?(parent, keyword, *args, &block)
37
+ initial_condition = (keyword == 'c_tab_item') and parent.respond_to?(:swt_widget)
38
+ if initial_condition
39
+ if parent.swt_widget.is_a?(CTabFolder)
40
+ return true
41
+ else
42
+ Glimmer::Config.logger.error {"c_tab_item widget may only be used directly under a c_tab_folder widget!"}
43
+ end
44
+ end
45
+ false
46
+ end
47
+
48
+ def interpret(parent, keyword, *args, &block)
49
+ Glimmer::SWT::CTabItemProxy.new(parent, args)
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -29,12 +29,13 @@ module Glimmer
29
29
  module SWT
30
30
  class ComboSelectionDataBindingExpression < Expression
31
31
  include_package 'org.eclipse.swt.widgets'
32
+ include_package 'org.eclipse.swt.custom'
32
33
 
33
34
  def can_interpret?(parent, keyword, *args, &block)
34
35
  keyword == 'selection' and
35
36
  block.nil? and
36
37
  parent.respond_to?(:swt_widget) and
37
- parent.swt_widget.is_a?(Combo) and
38
+ (parent.swt_widget.is_a?(Combo) || parent.swt_widget.is_a?(CCombo)) and
38
39
  args.size == 1 and
39
40
  args[0].is_a?(DataBinding::ModelBinding) and
40
41
  args[0].evaluate_options_property.is_a?(Array)
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2021 Andy Maleh
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -48,7 +48,11 @@ module Glimmer
48
48
  def interpret(parent, keyword, *args, &block)
49
49
  Glimmer::SWT::TabItemProxy.new(parent, args)
50
50
  end
51
+
51
52
  end
53
+
52
54
  end
55
+
53
56
  end
57
+
54
58
  end
@@ -30,7 +30,7 @@ module Glimmer
30
30
  class WidgetExpression < Expression
31
31
  include ParentExpression
32
32
 
33
- EXCLUDED_KEYWORDS = %w[shell display tab_item] + Glimmer::SWT::Custom::Shape.keywords - ['text']
33
+ EXCLUDED_KEYWORDS = %w[shell display tab_item c_tab_item] + Glimmer::SWT::Custom::Shape.keywords - ['text']
34
34
 
35
35
  def can_interpret?(parent, keyword, *args, &block)
36
36
  !EXCLUDED_KEYWORDS.include?(keyword) and
@@ -35,7 +35,7 @@ module Glimmer
35
35
 
36
36
  TEXT_USAGE = <<~MULTI_LINE_STRING
37
37
  Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v#{File.read(File.expand_path('../../../VERSION', __FILE__))}
38
- Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
38
+ Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args])
39
39
 
40
40
  Runs Glimmer applications and tasks.
41
41
 
@@ -67,8 +67,6 @@ module Glimmer
67
67
  }
68
68
  REGEX_RAKE_TASK_WITH_ARGS = /^([^\[]+)\[?([^\]]*)\]?$/
69
69
 
70
- @@mutex = Mutex.new
71
-
72
70
  class << self
73
71
  def platform_os
74
72
  OPERATING_SYSTEMS_SUPPORTED.detect {|os| OS.send("#{os}?")}
@@ -83,14 +81,12 @@ module Glimmer
83
81
  end
84
82
 
85
83
  def glimmer_lib
86
- @@mutex.synchronize do
87
- unless @glimmer_lib
88
- @glimmer_lib = GLIMMER_LIB_GEM
89
- glimmer_gem_listing = `jgem list #{GLIMMER_LIB_GEM}`.split("\n").map {|l| l.split.first}
90
- if !glimmer_gem_listing.include?(GLIMMER_LIB_GEM) && File.exists?(GLIMMER_LIB_LOCAL)
91
- @glimmer_lib = GLIMMER_LIB_LOCAL
92
- puts "[DEVELOPMENT MODE] (detected #{@glimmer_lib})"
93
- end
84
+ unless @glimmer_lib
85
+ @glimmer_lib = GLIMMER_LIB_GEM
86
+ glimmer_gem_listing = `jgem list #{GLIMMER_LIB_GEM}`.split("\n").map {|l| l.split.first}
87
+ if !glimmer_gem_listing.include?(GLIMMER_LIB_GEM) && File.exists?(GLIMMER_LIB_LOCAL)
88
+ @glimmer_lib = GLIMMER_LIB_LOCAL
89
+ puts "[DEVELOPMENT MODE] (detected #{@glimmer_lib})"
94
90
  end
95
91
  end
96
92
  @glimmer_lib
@@ -115,17 +111,12 @@ module Glimmer
115
111
  def launch(application, jruby_options: [], env_vars: {}, glimmer_options: {})
116
112
  jruby_options_string = jruby_options.join(' ') + ' ' if jruby_options.any?
117
113
  env_vars = env_vars.merge(glimmer_option_env_vars(glimmer_options))
118
- env_vars_string = env_vars.map do |k,v|
119
- if OS.windows? && ENV['PROMPT'] # detect command prompt (or powershell)
120
- "set #{k}=#{v} && "
121
- else
122
- "export #{k}=#{v} && "
123
- end
124
- end.join
114
+ env_vars.each do |k,v|
115
+ ENV[k] = v
116
+ end
125
117
  the_glimmer_lib = glimmer_lib
126
- devmode_require = nil
127
118
  if the_glimmer_lib == GLIMMER_LIB_LOCAL
128
- devmode_require = '-r puts_debuggerer '
119
+ require 'puts_debuggerer'
129
120
  end
130
121
  require_relative 'rake_task'
131
122
  rake_tasks = Rake.application.tasks.map(&:to_s).map {|t| t.sub('glimmer:', '')}
@@ -142,20 +133,9 @@ module Glimmer
142
133
  puts "Running Glimmer rake task: #{rake_task}" if jruby_options_string.to_s.include?('--debug')
143
134
  Rake::Task[rake_task].invoke(*rake_task_args)
144
135
  else
145
- @@mutex.synchronize do
146
- puts "Launching Glimmer Application: #{application}" if jruby_options_string.to_s.include?('--debug') || glimmer_options['--quiet'].to_s.downcase != 'true'
147
- end
148
- command = "#{env_vars_string} jruby #{jruby_options_string}#{jruby_os_specific_options} #{devmode_require}-r #{the_glimmer_lib} -S #{application}"
149
- if !env_vars_string.empty? && OS.windows?
150
- command = "bash -c \"#{command}\"" if ENV['SHELL'] # do in Windows Git Bash only
151
- command = "cmd /C \"#{command}\"" if ENV['PROMPT'] # do in Windows Command Prompt only (or Powershell)
152
- end
153
- puts command if jruby_options_string.to_s.include?('--debug')
154
- if command.include?(' irb ')
155
- exec command
156
- else
157
- system command
158
- end
136
+ puts "Launching Glimmer Application: #{application}" if jruby_options_string.to_s.include?('--debug') || glimmer_options['--quiet'].to_s.downcase != 'true'
137
+ require the_glimmer_lib
138
+ load File.expand_path(application)
159
139
  end
160
140
  end
161
141
  end
@@ -168,14 +148,14 @@ module Glimmer
168
148
  def initialize(raw_options)
169
149
  raw_options << '--quiet' if !caller.join("\n").include?('/bin/glimmer:') && !raw_options.join.include?('--quiet=')
170
150
  raw_options << '--log-level=DEBUG' if raw_options.join.include?('--debug') && !raw_options.join.include?('--log-level=')
171
- @application_paths = extract_application_paths(raw_options)
151
+ @application_path = extract_application_path(raw_options)
172
152
  @env_vars = extract_env_vars(raw_options)
173
153
  @glimmer_options = extract_glimmer_options(raw_options)
174
154
  @jruby_options = raw_options
175
155
  end
176
156
 
177
157
  def launch
178
- if @application_paths.empty?
158
+ if @application_path.nil?
179
159
  display_usage
180
160
  else
181
161
  launch_application
@@ -185,18 +165,13 @@ module Glimmer
185
165
  private
186
166
 
187
167
  def launch_application
188
- load File.expand_path('./Rakefile') if File.exist?(File.expand_path('./Rakefile')) && caller.join("\n").include?('/bin/glimmer:')
189
- threads = @application_paths.map do |application_path|
190
- Thread.new do
191
- self.class.launch(
192
- application_path,
193
- jruby_options: @jruby_options,
194
- env_vars: @env_vars,
195
- glimmer_options: @glimmer_options
196
- )
197
- end
198
- end
199
- threads.each(&:join)
168
+ load File.expand_path('./Rakefile') if File.exist?(File.expand_path('./Rakefile')) && caller.join("\n").include?('/bin/glimmer_runner.rb:')
169
+ self.class.launch(
170
+ @application_path,
171
+ jruby_options: @jruby_options,
172
+ env_vars: @env_vars,
173
+ glimmer_options: @glimmer_options
174
+ )
200
175
  end
201
176
 
202
177
  def display_usage
@@ -232,10 +207,11 @@ module Glimmer
232
207
  end
233
208
  end
234
209
 
235
- def extract_application_paths(options)
236
- options.select do |option|
210
+ # Extract application path (which can also be a rake task, basically a non-arg)
211
+ def extract_application_path(options)
212
+ application_path = options.detect do |option|
237
213
  !option.start_with?('-') && !option.include?('=')
238
- end.each do |application_path|
214
+ end.tap do
239
215
  options.delete(application_path)
240
216
  end
241
217
  end
@@ -100,7 +100,7 @@ namespace :glimmer do
100
100
 
101
101
  desc 'Generate Native files. type can be dmg/pkg on the Mac, msi/exe on Windows, and rpm/deb on Linux (type is optional)'
102
102
  task :native, [:type] do |t, args|
103
- extra_args = ARGV.partition {|arg| arg.include?('package:native')}.last.to_a.join(' ')
103
+ extra_args = ARGV.partition {|arg| arg.start_with?('package')}.last.to_a.join(' ')
104
104
  Glimmer::RakeTask::Package.native(args[:type], extra_args)
105
105
  end
106
106
  end
@@ -90,8 +90,12 @@ module Glimmer
90
90
 
91
91
  def native(native_type=nil, native_extra_args)
92
92
  puts "Generating native executable with javapackager/jpackage..."
93
- java_version = `java -version`
94
- puts "WARNING! Glimmer Packaging Pre-Requisite Java Version 1.8.0_241 Is Not Found!" unless java_version.include?('1.8.0_241')
93
+ java_version = `jruby -v`
94
+ if java_version.include?('1.8.0_241')
95
+ puts "Java Version 1.8.0_241 Detected!"
96
+ else
97
+ puts "WARNING! Glimmer Packaging Pre-Requisite Java Version 1.8.0_241 Is Not Found!"
98
+ end
95
99
  require 'facets/string/titlecase'
96
100
  require 'facets/string/underscore'
97
101
  require 'facets/string/camelcase'
@@ -121,6 +125,7 @@ module Glimmer
121
125
  puts "Neither javapackager nor jpackage exist in your Java installation. Please ensure javapackager or jpackage is available in PATH environment variable."
122
126
  return
123
127
  end
128
+ Rake.application.load_rakefile # make sure to load potential javapackager_extra_args config in app Rakefile
124
129
  command += " #{javapackager_extra_args} " if javapackager_extra_args
125
130
  command += " #{ENV['JAVAPACKAGER_EXTRA_ARGS']} " if ENV['JAVAPACKAGER_EXTRA_ARGS']
126
131
  command += " #{native_extra_args} " if native_extra_args
@@ -149,8 +149,8 @@ module Glimmer
149
149
  write 'Rakefile', gem_rakefile(app_name, nil, gem_name)
150
150
  mkdir 'app'
151
151
  write "app/#{file_name(app_name)}.rb", app_main_file(app_name)
152
- mkdir 'app/models'
153
- mkdir 'app/views'
152
+ mkdir_p "app/#{file_name(app_name)}/model"
153
+ mkdir_p "app/#{file_name(app_name)}/view"
154
154
  if shell_type == :desktopify
155
155
  custom_shell('AppView', current_dir_name, shell_type, shell_options)
156
156
  else
@@ -185,7 +185,7 @@ module Glimmer
185
185
  end
186
186
  write 'spec/spec_helper.rb', spec_helper_file
187
187
  if OS.windows?
188
- system "glimmer package[image]"
188
+ system "glimmer \"package[image]\"" # TODO handle Windows with batch file
189
189
  system "\"packages/bundles/#{human_name(app_name)}/#{human_name(app_name)}.exe\""
190
190
  else
191
191
  system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer package\n'"
@@ -200,7 +200,7 @@ module Glimmer
200
200
  def custom_shell(custom_shell_name, namespace, shell_type = nil, shell_options = {})
201
201
  namespace ||= current_dir_name
202
202
  root_dir = File.exists?('app') ? 'app' : 'lib'
203
- parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
203
+ parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
204
204
  return puts("The file '#{parent_dir}/#{file_name(custom_shell_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_shell_name)}.rb")
205
205
  mkdir_p parent_dir unless File.exists?(parent_dir)
206
206
  write "#{parent_dir}/#{file_name(custom_shell_name)}.rb", custom_shell_file(custom_shell_name, namespace, shell_type, shell_options)
@@ -209,7 +209,7 @@ module Glimmer
209
209
  def custom_widget(custom_widget_name, namespace)
210
210
  namespace ||= current_dir_name
211
211
  root_dir = File.exists?('app') ? 'app' : 'lib'
212
- parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
212
+ parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
213
213
  return puts("The file '#{parent_dir}/#{file_name(custom_widget_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_widget_name)}.rb")
214
214
  mkdir_p parent_dir unless File.exists?(parent_dir)
215
215
  write "#{parent_dir}/#{file_name(custom_widget_name)}.rb", custom_widget_file(custom_widget_name, namespace)
@@ -218,7 +218,7 @@ module Glimmer
218
218
  def custom_shape(custom_shape_name, namespace)
219
219
  namespace ||= current_dir_name
220
220
  root_dir = File.exists?('app') ? 'app' : 'lib'
221
- parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
221
+ parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
222
222
  return puts("The file '#{parent_dir}/#{file_name(custom_shape_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_shape_name)}.rb")
223
223
  mkdir_p parent_dir unless File.exists?(parent_dir)
224
224
  write "#{parent_dir}/#{file_name(custom_shape_name)}.rb", custom_shape_file(custom_shape_name, namespace)
@@ -253,15 +253,12 @@ module Glimmer
253
253
  write 'Gemfile', GEMFILE
254
254
  write 'Rakefile', gem_rakefile(custom_shell_name, namespace, gem_name)
255
255
  append "lib/#{gem_name}.rb", gem_main_file(custom_shell_name, namespace)
256
- mkdir 'lib/views'
257
256
  custom_shell(custom_shell_name, namespace, :gem)
258
257
 
259
- mkdir_p "lib/#{file_name(namespace)}/#{file_name(custom_shell_name)}"
260
- write "lib/#{file_name(namespace)}/#{file_name(custom_shell_name)}/launch.rb", gem_launch_file(gem_name, custom_shell_name, namespace)
258
+ mkdir_p "lib/#{gem_name}"
259
+ write "lib/#{gem_name}/launch.rb", gem_launch_file(gem_name, custom_shell_name, namespace)
261
260
  mkdir_p 'bin'
262
- write "bin/#{gem_name}", gem_bin_command_file(gem_name, custom_shell_name, namespace)
263
- FileUtils.chmod 0755, "bin/#{gem_name}"
264
- write "bin/#{file_name(custom_shell_name)}", gem_bin_command_file(gem_name, custom_shell_name, namespace)
261
+ write "bin/#{file_name(custom_shell_name)}", app_bin_command_file(gem_name, custom_shell_name, namespace)
265
262
  FileUtils.chmod 0755, "bin/#{file_name(custom_shell_name)}"
266
263
  if OS.windows?
267
264
  system "bundle"
@@ -287,12 +284,12 @@ module Glimmer
287
284
  puts "Created #{current_dir_name}/#{icon_file}"
288
285
 
289
286
  if OS.windows?
290
- system "glimmer package[image]"
287
+ system "glimmer package[image]" # TODO handle windows properly with batch file
291
288
  system "\"packages/bundles/#{human_name(custom_shell_name)}/#{human_name(custom_shell_name)}.exe\""
292
289
  else
293
290
  system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer package\n'"
294
291
  if OS.mac?
295
- system "open packages/bundles/#{human_name(custom_shell_name).gsub(' ', '\ ')}.app" if OS.mac?
292
+ system "open packages/bundles/#{human_name(custom_shell_name).gsub(' ', '\ ')}.app"
296
293
  else
297
294
  system "glimmer run"
298
295
  end
@@ -327,7 +324,6 @@ module Glimmer
327
324
  write 'Gemfile', GEMFILE
328
325
  write 'Rakefile', gem_rakefile
329
326
  append "lib/#{gem_name}.rb", gem_main_file(custom_widget_name, namespace)
330
- mkdir 'lib/views'
331
327
  custom_widget(custom_widget_name, namespace)
332
328
  if OS.windows?
333
329
  system "bundle"
@@ -366,7 +362,6 @@ module Glimmer
366
362
  write 'Gemfile', GEMFILE
367
363
  write 'Rakefile', gem_rakefile
368
364
  append "lib/#{gem_name}.rb", gem_main_file(custom_shape_name, namespace)
369
- mkdir 'lib/views'
370
365
  custom_shape(custom_shape_name, namespace)
371
366
  if OS.windows?
372
367
  system "bundle"
@@ -443,7 +438,7 @@ module Glimmer
443
438
 
444
439
  require 'bundler/setup'
445
440
  Bundler.require(:default)
446
- require 'views/#{file_name(app_name)}/app_view'
441
+ require '#{file_name(app_name)}/view/app_view'
447
442
 
448
443
  class #{class_name(app_name)}
449
444
  include Glimmer
@@ -451,17 +446,14 @@ module Glimmer
451
446
  APP_ROOT = File.expand_path('../..', __FILE__)
452
447
  VERSION = File.read(File.join(APP_ROOT, 'VERSION'))
453
448
  LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
454
-
455
- def open
456
- app_view.open
457
- end
458
449
  end
459
450
  MULTI_LINE_STRING
460
451
  end
461
452
 
462
453
  def gem_main_file(custom_widget_name, namespace = nil)
463
- custom_widget_file_path = "views"
464
- custom_widget_file_path += "/#{file_name(namespace)}" if namespace
454
+ custom_widget_file_path = ''
455
+ custom_widget_file_path += "#{file_name(namespace)}/" if namespace
456
+ custom_widget_file_path += "view"
465
457
  custom_widget_file_path += "/#{file_name(custom_widget_name)}"
466
458
 
467
459
  <<~MULTI_LINE_STRING
@@ -476,15 +468,20 @@ module Glimmer
476
468
  <<~MULTI_LINE_STRING
477
469
  require_relative '../#{file_name(app_name)}'
478
470
 
479
- #{class_name(app_name)}.new.open
471
+ #{class_name(app_name)}::View::AppView.launch
480
472
  MULTI_LINE_STRING
481
473
  end
482
474
 
483
- def app_bin_command_file(app_name)
475
+ def app_bin_command_file(app_name_or_gem_name, custom_shell_name=nil, namespace=nil)
476
+ if custom_shell_name.nil?
477
+ runner = "File.expand_path('../../app/#{file_name(app_name_or_gem_name)}/launch.rb', __FILE__)"
478
+ else
479
+ runner = "File.expand_path('../../lib/#{app_name_or_gem_name}/launch.rb', __FILE__)"
480
+ end
484
481
  <<~MULTI_LINE_STRING
485
482
  #!/usr/bin/env jruby
486
483
 
487
- runner = File.expand_path("../../app/#{file_name(app_name)}/launch.rb", __FILE__)
484
+ runner = #{runner}
488
485
 
489
486
  # Detect if inside a JAR file or not
490
487
  if runner.include?('uri:classloader')
@@ -501,39 +498,9 @@ module Glimmer
501
498
  def gem_launch_file(gem_name, custom_shell_name, namespace)
502
499
  # TODO change this so that it does not mix Glimmer unto the main object
503
500
  <<~MULTI_LINE_STRING
504
- require_relative '../../#{gem_name}'
505
-
506
- module #{class_name(namespace)}
507
- class #{class_name(custom_shell_name)}
508
- class App
509
- include Glimmer
510
-
511
- def open
512
- #{dsl_widget_name(custom_shell_name)}.open
513
- end
514
- end
515
- end
516
- end
517
-
518
- #{class_name(namespace)}::#{class_name(custom_shell_name)}::App.new.open
519
- MULTI_LINE_STRING
520
- end
521
-
522
- def gem_bin_command_file(gem_name, custom_shell_name, namespace)
523
- <<~MULTI_LINE_STRING
524
- #!/usr/bin/env jruby
525
-
526
- runner = File.expand_path("../../lib/#{file_name(namespace)}/#{file_name(custom_shell_name)}/launch.rb", __FILE__)
501
+ require_relative '../#{gem_name}'
527
502
 
528
- # Detect if inside a JAR file or not
529
- if runner.include?('uri:classloader')
530
- require runner
531
- else
532
- require 'glimmer/launcher'
533
-
534
- launcher = Glimmer::Launcher.new([runner] + ARGV)
535
- launcher.launch
536
- end
503
+ #{class_name(namespace)}::View::#{class_name(custom_shell_name)}.launch
537
504
  MULTI_LINE_STRING
538
505
  end
539
506
 
@@ -546,8 +513,8 @@ module Glimmer
546
513
  if custom_shell_name
547
514
  lines.insert(gem_files_line_index, " gem.files = Dir['VERSION', 'LICENSE.txt', 'app/**/*', 'bin/**/*', 'config/**/*', 'db/**/*', 'docs/**/*', 'fonts/**/*', 'icons/**/*', 'images/**/*', 'lib/**/*', 'package/**/*', 'script/**/*', 'sounds/**/*', 'vendor/**/*', 'videos/**/*']")
548
515
  # the second executable is needed for warbler as it matches the gem name, which is the default expected file (alternatively in the future, we could do away with it and configure warbler to use the other file)
549
- lines.insert(gem_files_line_index+1, " gem.executables = ['#{gem_name}', '#{file_name(custom_shell_name)}']")
550
- lines.insert(gem_files_line_index+2, " gem.require_paths = ['vendor', 'lib', 'app']")
516
+ lines.insert(gem_files_line_index+1, " gem.require_paths = ['vendor', 'lib', 'app']")
517
+ lines.insert(gem_files_line_index+2, " gem.executables = ['#{file_name(custom_shell_name)}']") if custom_shell_name
551
518
  else
552
519
  lines.insert(gem_files_line_index, " gem.files = Dir['VERSION', 'LICENSE.txt', 'lib/**/*']")
553
520
  end
@@ -595,270 +562,276 @@ module Glimmer
595
562
  namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
596
563
 
597
564
  custom_shell_file_content = <<-MULTI_LINE_STRING
598
- #{namespace_type} #{class_name(namespace)}
599
- class #{class_name(custom_shell_name)}
600
- include Glimmer::UI::CustomShell
601
-
565
+ #{namespace_type} #{class_name(namespace)}
566
+ module View
567
+ class #{class_name(custom_shell_name)}
568
+ include Glimmer::UI::CustomShell
569
+
602
570
  MULTI_LINE_STRING
603
571
 
604
572
  if shell_type == :gem
605
573
  custom_shell_file_content += <<-MULTI_LINE_STRING
606
- APP_ROOT = File.expand_path('../../../..', __FILE__)
607
- VERSION = File.read(File.join(APP_ROOT, 'VERSION'))
608
- LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
609
-
574
+ APP_ROOT = File.expand_path('../../../..', __FILE__)
575
+ VERSION = File.read(File.join(APP_ROOT, 'VERSION'))
576
+ LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
577
+
610
578
  MULTI_LINE_STRING
611
579
  end
612
580
 
613
581
  custom_shell_file_content += <<-MULTI_LINE_STRING
614
- ## Add options like the following to configure CustomShell by outside consumers
615
- #
616
- # options :title, :background_color
617
- # option :width, default: 320
618
- # option :height, default: 240
619
- #{'# ' if shell_type == :desktopify}option :greeting, default: 'Hello, World!'
620
-
621
- ## Use before_body block to pre-initialize variables to use in body
622
- #
623
- #
582
+ ## Add options like the following to configure CustomShell by outside consumers
583
+ #
584
+ # options :title, :background_color
585
+ # option :width, default: 320
586
+ # option :height, default: 240
587
+ #{'# ' if shell_type == :desktopify}option :greeting, default: 'Hello, World!'
588
+
589
+ ## Use before_body block to pre-initialize variables to use in body
590
+ #
591
+ #
624
592
  MULTI_LINE_STRING
625
593
 
626
594
  if %i[gem app desktopify].include?(shell_type)
627
595
  custom_shell_file_content += <<-MULTI_LINE_STRING
628
- before_body {
629
- Display.app_name = '#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}'
630
- Display.app_version = VERSION
631
- @display = display {
632
- on_about {
633
- display_about_dialog
634
- }
635
- on_preferences {
636
- #{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
637
- }
596
+ before_body {
597
+ Display.app_name = '#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}'
598
+ Display.app_version = VERSION
599
+ @display = display {
600
+ on_about {
601
+ display_about_dialog
602
+ }
603
+ on_preferences {
604
+ #{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
638
605
  }
639
606
  }
607
+ }
640
608
  MULTI_LINE_STRING
641
609
  else
642
610
  custom_shell_file_content += <<-MULTI_LINE_STRING
643
- # before_body {
644
- #
645
- # }
611
+ # before_body {
612
+ #
613
+ # }
646
614
  MULTI_LINE_STRING
647
615
  end
648
616
 
649
617
  custom_shell_file_content += <<-MULTI_LINE_STRING
650
-
651
- ## Use after_body block to setup observers for widgets in body
652
- #
653
- # after_body {
654
- #
655
- # }
656
-
657
- ## Add widget content inside custom shell body
658
- ## Top-most widget must be a shell or another custom shell
659
- #
660
- body {
661
- shell {
662
- # Replace example content below with custom shell content
663
- minimum_size #{shell_type == :desktopify ? '1024, 768' : '320, 240'}
664
- image File.join(APP_ROOT, 'package', 'windows', "#{human_name(shell_type == :gem ? custom_shell_name : current_dir_name)}.ico") if OS.windows?
665
- text "#{human_name(namespace)} - #{human_name(custom_shell_name)}"
666
-
618
+
619
+ ## Use after_body block to setup observers for widgets in body
620
+ #
621
+ # after_body {
622
+ #
623
+ # }
624
+
625
+ ## Add widget content inside custom shell body
626
+ ## Top-most widget must be a shell or another custom shell
627
+ #
628
+ body {
629
+ shell(#{':fill_screen' if shell_type == :desktopify}) {
630
+ # Replace example content below with custom shell content
631
+ minimum_size #{shell_type == :desktopify ? '768, 432' : '420, 240'}
632
+ image File.join(APP_ROOT, 'package', 'windows', "#{human_name(shell_type == :gem ? custom_shell_name : current_dir_name)}.ico") if OS.windows?
633
+ text "#{human_name(namespace)} - #{human_name(custom_shell_name)}"
634
+
667
635
  MULTI_LINE_STRING
668
636
 
669
637
  if shell_type == :desktopify
670
638
  custom_shell_file_content += <<-MULTI_LINE_STRING
671
- browser {
672
- url "#{shell_options[:website]}"
673
- }
639
+ browser {
640
+ url "#{shell_options[:website]}"
641
+ }
674
642
  MULTI_LINE_STRING
675
643
  else
676
644
  custom_shell_file_content += <<-MULTI_LINE_STRING
677
- grid_layout
678
- label(:center) {
679
- text bind(self, :greeting)
680
- font height: 40
681
- layout_data :fill, :center, true, true
682
- }
645
+ grid_layout
646
+ label(:center) {
647
+ text bind(self, :greeting)
648
+ font height: 40
649
+ layout_data :fill, :center, true, true
650
+ }
683
651
  MULTI_LINE_STRING
684
652
  end
685
653
 
686
654
  if %i[gem app desktopify].include?(shell_type)
687
655
  custom_shell_file_content += <<-MULTI_LINE_STRING
688
-
689
- menu_bar {
690
- menu {
691
- text '&File'
692
- menu_item {
693
- text '&About...'
694
- on_widget_selected {
695
- display_about_dialog
696
- }
656
+
657
+ menu_bar {
658
+ menu {
659
+ text '&File'
660
+ menu_item {
661
+ text '&About...'
662
+ on_widget_selected {
663
+ display_about_dialog
697
664
  }
698
- menu_item {
699
- text '&Preferences...'
700
- on_widget_selected {
701
- #{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
702
- }
665
+ }
666
+ menu_item {
667
+ text '&Preferences...'
668
+ on_widget_selected {
669
+ #{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
703
670
  }
704
671
  }
705
672
  }
673
+ }
706
674
  MULTI_LINE_STRING
707
675
  end
708
676
 
709
677
  custom_shell_file_content += <<-MULTI_LINE_STRING
710
- }
711
678
  }
679
+ }
712
680
  MULTI_LINE_STRING
713
681
 
714
682
  if %i[gem app desktopify].include?(shell_type)
715
683
  custom_shell_file_content += <<-MULTI_LINE_STRING
716
-
717
- def display_about_dialog
718
- message_box(body_root) {
719
- text 'About'
720
- message "#{human_name(namespace)}#{" - #{human_name(custom_shell_name)}" if shell_type == :gem} \#{VERSION}\\n\\n\#{LICENSE}"
721
- }.open
722
- end
723
-
684
+
685
+ def display_about_dialog
686
+ message_box(body_root) {
687
+ text 'About'
688
+ message "#{human_name(namespace)}#{" - #{human_name(custom_shell_name)}" if shell_type == :gem} \#{VERSION}\\n\\n\#{LICENSE}"
689
+ }.open
690
+ end
691
+
724
692
  MULTI_LINE_STRING
725
693
  end
726
694
 
727
695
  if %i[gem app].include?(shell_type)
728
696
  custom_shell_file_content += <<-MULTI_LINE_STRING
729
- def display_preferences_dialog
730
- dialog(swt_widget) {
731
- text 'Preferences'
732
- grid_layout {
733
- margin_height 5
734
- margin_width 5
697
+ def display_preferences_dialog
698
+ dialog(swt_widget) {
699
+ text 'Preferences'
700
+ grid_layout {
701
+ margin_height 5
702
+ margin_width 5
703
+ }
704
+ group {
705
+ row_layout {
706
+ type :vertical
707
+ spacing 10
735
708
  }
736
- group {
737
- row_layout {
738
- type :vertical
739
- spacing 10
740
- }
741
- text 'Greeting'
742
- font style: :bold
743
- [
744
- 'Hello, World!',
745
- 'Howdy, Partner!'
746
- ].each do |greeting_text|
747
- button(:radio) {
748
- text greeting_text
749
- selection bind(self, :greeting) { |g| g == greeting_text }
750
- layout_data {
751
- width 160
752
- }
753
- on_widget_selected { |event|
754
- self.greeting = event.widget.getText
755
- }
709
+ text 'Greeting'
710
+ font style: :bold
711
+ [
712
+ 'Hello, World!',
713
+ 'Howdy, Partner!'
714
+ ].each do |greeting_text|
715
+ button(:radio) {
716
+ text greeting_text
717
+ selection bind(self, :greeting) { |g| g == greeting_text }
718
+ layout_data {
719
+ width 160
756
720
  }
757
- end
758
- }
759
- }.open
760
- end
721
+ on_widget_selected { |event|
722
+ self.greeting = event.widget.getText
723
+ }
724
+ }
725
+ end
726
+ }
727
+ }.open
728
+ end
761
729
  MULTI_LINE_STRING
762
730
  end
763
731
 
764
732
  custom_shell_file_content += <<-MULTI_LINE_STRING
765
- end
766
733
  end
734
+ end
735
+ end
767
736
  MULTI_LINE_STRING
768
737
  end
769
738
 
770
739
  def custom_widget_file(custom_widget_name, namespace)
771
740
  namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
772
741
 
773
- <<~MULTI_LINE_STRING
774
- #{namespace_type} #{class_name(namespace)}
775
- class #{class_name(custom_widget_name)}
776
- include Glimmer::UI::CustomWidget
777
-
778
- ## Add options like the following to configure CustomWidget by outside consumers
779
- #
780
- # options :custom_text, :background_color
781
- # option :foreground_color, default: :red
782
-
783
- ## Use before_body block to pre-initialize variables to use in body
784
- #
785
- #
786
- # before_body {
787
- #
788
- # }
789
-
790
- ## Use after_body block to setup observers for widgets in body
791
- #
792
- # after_body {
793
- #
794
- # }
795
-
796
- ## Add widget content under custom widget body
797
- ##
798
- ## If you want to add a shell as the top-most widget,
799
- ## consider creating a custom shell instead
800
- ## (Glimmer::UI::CustomShell offers shell convenience methods, like show and hide)
801
- #
802
- body {
803
- # Replace example content below with custom widget content
804
- label {
805
- background :red
806
- }
807
- }
808
-
809
- end
810
- end
742
+ <<-MULTI_LINE_STRING
743
+ #{namespace_type} #{class_name(namespace)}
744
+ module View
745
+ class #{class_name(custom_widget_name)}
746
+ include Glimmer::UI::CustomWidget
747
+
748
+ ## Add options like the following to configure CustomWidget by outside consumers
749
+ #
750
+ # options :custom_text, :background_color
751
+ # option :foreground_color, default: :red
752
+
753
+ ## Use before_body block to pre-initialize variables to use in body
754
+ #
755
+ #
756
+ # before_body {
757
+ #
758
+ # }
759
+
760
+ ## Use after_body block to setup observers for widgets in body
761
+ #
762
+ # after_body {
763
+ #
764
+ # }
765
+
766
+ ## Add widget content under custom widget body
767
+ ##
768
+ ## If you want to add a shell as the top-most widget,
769
+ ## consider creating a custom shell instead
770
+ ## (Glimmer::UI::CustomShell offers shell convenience methods, like show and hide)
771
+ #
772
+ body {
773
+ # Replace example content below with custom widget content
774
+ label {
775
+ background :red
776
+ }
777
+ }
778
+
779
+ end
780
+ end
781
+ end
811
782
  MULTI_LINE_STRING
812
783
  end
813
784
 
814
785
  def custom_shape_file(custom_shape_name, namespace)
815
786
  namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
816
787
 
817
- <<~MULTI_LINE_STRING
818
- #{namespace_type} #{class_name(namespace)}
819
- class #{class_name(custom_shape_name)}
820
- include Glimmer::UI::CustomShape
821
-
822
- ## Add options like the following to configure CustomShape by outside consumers
823
- #
824
- # options :option1, option2, option3
825
- option :background_color, default: :red
826
- option :size_width, default: 100
827
- option :size_height, default: 100
828
- option :location_x, default: 0
829
- option :location_y, default: 0
830
-
831
- ## Use before_body block to pre-initialize variables to use in body
832
- #
833
- #
834
- # before_body {
835
- #
836
- # }
837
-
838
- ## Use after_body block to setup observers for shapes in body
839
- #
840
- # after_body {
841
- #
842
- # }
843
-
844
- ## Add shape content under custom shape body
845
- #
846
- body {
847
- # Replace example content below with custom shape content
848
- shape(location_x, location_y) {
849
- path {
850
- background background_color
851
- cubic size_width - size_width*0.66, size_height/2 - size_height*0.33, size_width*0.65 - size_width*0.66, 0 - size_height*0.33, size_width/2 - size_width*0.66, size_height*0.75 - size_height*0.33, size_width - size_width*0.66, size_height - size_height*0.33
852
- }
853
- path {
854
- background background_color
855
- cubic size_width - size_width*0.66, size_height/2 - size_height*0.33, size_width*1.35 - size_width*0.66, 0 - size_height*0.33, size_width*1.5 - size_width*0.66, size_height*0.75 - size_height*0.33, size_width - size_width*0.66, size_height - size_height*0.33
856
- }
857
- }
858
- }
859
-
860
- end
861
- end
788
+ <<-MULTI_LINE_STRING
789
+ #{namespace_type} #{class_name(namespace)}
790
+ module View
791
+ class #{class_name(custom_shape_name)}
792
+ include Glimmer::UI::CustomShape
793
+
794
+ ## Add options like the following to configure CustomShape by outside consumers
795
+ #
796
+ # options :option1, option2, option3
797
+ option :background_color, default: :red
798
+ option :size_width, default: 100
799
+ option :size_height, default: 100
800
+ option :location_x, default: 0
801
+ option :location_y, default: 0
802
+
803
+ ## Use before_body block to pre-initialize variables to use in body
804
+ #
805
+ #
806
+ # before_body {
807
+ #
808
+ # }
809
+
810
+ ## Use after_body block to setup observers for shapes in body
811
+ #
812
+ # after_body {
813
+ #
814
+ # }
815
+
816
+ ## Add shape content under custom shape body
817
+ #
818
+ body {
819
+ # Replace example content below with custom shape content
820
+ shape(location_x, location_y) {
821
+ path {
822
+ background background_color
823
+ cubic size_width - size_width*0.66, size_height/2 - size_height*0.33, size_width*0.65 - size_width*0.66, 0 - size_height*0.33, size_width/2 - size_width*0.66, size_height*0.75 - size_height*0.33, size_width - size_width*0.66, size_height - size_height*0.33
824
+ }
825
+ path {
826
+ background background_color
827
+ cubic size_width - size_width*0.66, size_height/2 - size_height*0.33, size_width*1.35 - size_width*0.66, 0 - size_height*0.33, size_width*1.5 - size_width*0.66, size_height*0.75 - size_height*0.33, size_width - size_width*0.66, size_height - size_height*0.33
828
+ }
829
+ }
830
+ }
831
+
832
+ end
833
+ end
834
+ end
862
835
  MULTI_LINE_STRING
863
836
  end
864
837