glimmer-dsl-swt 4.17.2.3 → 4.17.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.2.3
1
+ 4.17.4.2
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-swt 4.17.2.3 ruby lib
5
+ # stub: glimmer-dsl-swt 4.17.4.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.17.2.3"
9
+ s.version = "4.17.4.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2020-10-16"
14
+ s.date = "2020-10-23"
15
15
  s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Library)".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
@@ -81,10 +81,10 @@ Gem::Specification.new do |s|
81
81
  "lib/glimmer/rake_task.rb",
82
82
  "lib/glimmer/rake_task/list.rb",
83
83
  "lib/glimmer/rake_task/package.rb",
84
- "lib/glimmer/rake_task/sample.rb",
85
84
  "lib/glimmer/rake_task/scaffold.rb",
86
85
  "lib/glimmer/swt/color_proxy.rb",
87
86
  "lib/glimmer/swt/cursor_proxy.rb",
87
+ "lib/glimmer/swt/custom/code_text.rb",
88
88
  "lib/glimmer/swt/display_proxy.rb",
89
89
  "lib/glimmer/swt/dnd_proxy.rb",
90
90
  "lib/glimmer/swt/font_proxy.rb",
@@ -94,9 +94,11 @@ Gem::Specification.new do |s|
94
94
  "lib/glimmer/swt/menu_proxy.rb",
95
95
  "lib/glimmer/swt/message_box_proxy.rb",
96
96
  "lib/glimmer/swt/packages.rb",
97
+ "lib/glimmer/swt/sash_form_proxy.rb",
97
98
  "lib/glimmer/swt/scrolled_composite_proxy.rb",
98
99
  "lib/glimmer/swt/shell_proxy.rb",
99
100
  "lib/glimmer/swt/style_constantizable.rb",
101
+ "lib/glimmer/swt/styled_text_proxy.rb",
100
102
  "lib/glimmer/swt/swt_proxy.rb",
101
103
  "lib/glimmer/swt/tab_item_proxy.rb",
102
104
  "lib/glimmer/swt/table_column_proxy.rb",
@@ -112,6 +114,7 @@ Gem::Specification.new do |s|
112
114
  "samples/elaborate/contact_manager/contact_manager_presenter.rb",
113
115
  "samples/elaborate/contact_manager/contact_repository.rb",
114
116
  "samples/elaborate/login.rb",
117
+ "samples/elaborate/meta_sample.rb",
115
118
  "samples/elaborate/tic_tac_toe.rb",
116
119
  "samples/elaborate/tic_tac_toe/board.rb",
117
120
  "samples/elaborate/tic_tac_toe/cell.rb",
@@ -128,6 +131,7 @@ Gem::Specification.new do |s|
128
131
  "samples/hello/hello_menu_bar.rb",
129
132
  "samples/hello/hello_message_box.rb",
130
133
  "samples/hello/hello_pop_up_context_menu.rb",
134
+ "samples/hello/hello_sash_form.rb",
131
135
  "samples/hello/hello_tab.rb",
132
136
  "samples/hello/hello_world.rb",
133
137
  "vendor/swt/linux/swt.jar",
@@ -155,7 +159,7 @@ Gem::Specification.new do |s|
155
159
  s.add_runtime_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
156
160
  s.add_runtime_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
157
161
  s.add_runtime_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
158
- s.add_runtime_dependency(%q<tty-markdown>.freeze, [">= 0.6.0", "< 2.0.0"])
162
+ s.add_runtime_dependency(%q<rouge>.freeze, [">= 3.23.0", "< 4.0.0"])
159
163
  s.add_development_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
160
164
  s.add_development_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
161
165
  s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
@@ -174,7 +178,7 @@ Gem::Specification.new do |s|
174
178
  s.add_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
175
179
  s.add_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
176
180
  s.add_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
177
- s.add_dependency(%q<tty-markdown>.freeze, [">= 0.6.0", "< 2.0.0"])
181
+ s.add_dependency(%q<rouge>.freeze, [">= 3.23.0", "< 4.0.0"])
178
182
  s.add_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
179
183
  s.add_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
180
184
  s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
@@ -34,6 +34,7 @@ require 'glimmer'
34
34
  require 'logging'
35
35
  require 'nested_inherited_jruby_include_package'
36
36
  require 'super_module'
37
+ require 'rouge'
37
38
 
38
39
  # Internal requires
39
40
  require 'ext/glimmer/config'
@@ -25,6 +25,7 @@ require 'glimmer/dsl/parent_expression'
25
25
  require 'glimmer/dsl/top_level_expression'
26
26
  require 'glimmer/ui/custom_widget'
27
27
  require 'glimmer/ui/custom_shell'
28
+ require 'glimmer/swt/custom/code_text'
28
29
 
29
30
  module Glimmer
30
31
  module DSL
@@ -56,3 +56,5 @@ require 'glimmer/swt/scrolled_composite_proxy'
56
56
  require 'glimmer/swt/tree_proxy'
57
57
  require 'glimmer/swt/table_proxy'
58
58
  require 'glimmer/swt/table_column_proxy'
59
+ require 'glimmer/swt/sash_form_proxy'
60
+ require 'glimmer/swt/styled_text_proxy'
@@ -48,26 +48,23 @@ require_relative '../ext/glimmer/config.rb'
48
48
  require 'puts_debuggerer' if ("#{ENV['pd']}#{ENV['PD']}").to_s.downcase.include?('true')
49
49
 
50
50
  namespace :glimmer do
51
- namespace :sample do
52
- task :requires do
53
- require_relative 'rake_task/sample'
51
+ desc 'Runs Glimmer app or custom shell gem in the current directory, unless app_path is specified, then runs it instead (app_path is optional)'
52
+ task :run, [:app_path] do |t, args|
53
+ require_relative 'launcher'
54
+ if args[:app_path].nil?
55
+ require 'fileutils'
56
+ current_directory_name = File.basename(FileUtils.pwd)
57
+ assumed_shell_script = File.join('.', 'bin', current_directory_name)
58
+ assumed_shell_script = Dir.glob('./bin/*').detect {|f| File.file?(f)} if !File.exist?(assumed_shell_script)
59
+ Glimmer::Launcher.new([assumed_shell_script]).launch
60
+ else
61
+ Glimmer::Launcher.new([args[:app_path]]).launch
54
62
  end
55
-
56
- desc 'Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples.'
57
- task :run, [:name] => [:requires] do |t, args|
58
- Glimmer::RakeTask::Sample.run(args[:name])
59
- end
60
-
61
- desc 'Lists Glimmer internal samples [included in gem]. Filters by query if specified (query is optional)'
62
- task :list, [:query] => [:requires] do |t, args|
63
- Glimmer::RakeTask::Sample.list(args[:query])
64
- end
65
-
66
- desc 'Outputs code for a Glimmer internal sample [included in gem] (name is required)'
67
- task :code, [:name] => [:requires] do |t, args|
68
- Glimmer::RakeTask::Sample.code(args[:name])
69
- end
70
-
63
+ end
64
+
65
+ desc 'Brings up the Glimmer Meta-Sample app to allow browsing, running, and viewing code of Glimmer samples'
66
+ task :samples do
67
+ Glimmer::Launcher.new([File.expand_path('../../../samples/elaborate/meta_sample.rb', __FILE__)]).launch
71
68
  end
72
69
 
73
70
  namespace :package do
@@ -81,6 +78,11 @@ namespace :glimmer do
81
78
  Glimmer::RakeTask::Package.gemspec
82
79
  end
83
80
 
81
+ desc 'Generate gem under pkg directory'
82
+ task :gem do
83
+ Glimmer::RakeTask::Package.gem
84
+ end
85
+
84
86
  desc 'Generate JAR config file'
85
87
  task :config do
86
88
  Glimmer::RakeTask::Package.config
@@ -109,7 +111,11 @@ namespace :glimmer do
109
111
  Rake::Task['glimmer:package:lock_jars'].execute
110
112
  Rake::Task['glimmer:package:config'].execute
111
113
  Rake::Task['glimmer:package:jar'].execute
112
- Rake::Task['glimmer:package:native'].execute(args)
114
+ if OS.linux?
115
+ Rake::Task['glimmer:package:gem'].execute
116
+ else
117
+ Rake::Task['glimmer:package:native'].execute(args)
118
+ end
113
119
  end
114
120
 
115
121
  desc 'Scaffold Glimmer application directory structure to build a new app'
@@ -139,6 +145,12 @@ namespace :glimmer do
139
145
  task :custom_widget, [:name, :namespace] => :customwidget
140
146
  task :"custom-widget", [:name, :namespace] => :customwidget
141
147
 
148
+ desc 'Desktopify a web app'
149
+ task :desktopify, [:app_name, :website] do |t, args|
150
+ require_relative 'rake_task/scaffold'
151
+ Glimmer::RakeTask::Scaffold.desktopify(args[:app_name], args[:website])
152
+ end
153
+
142
154
  namespace :gem do
143
155
  desc 'Scaffold Glimmer::UI::CustomShell subclass (full window view) under its own Ruby gem + app project (namespace is required) [alt: scaffold:gem:cs]'
144
156
  task :customshell, [:name, :namespace] do |t, args|
@@ -39,8 +39,12 @@ module Glimmer
39
39
  system 'rake gemspec:generate'
40
40
  end
41
41
 
42
+ def gem
43
+ system 'rake build'
44
+ end
45
+
42
46
  def lock_jars
43
- puts 'Locking gem jar-dependencies by downloading & storing in vendor/jars...'
47
+ puts 'Locking gem jar-dependencies by downloading and storing in vendor/jars...'
44
48
  FileUtils.mkdir_p('vendor/jars')
45
49
  command = "lock_jars --vendor-dir vendor/jars"
46
50
  puts command
@@ -85,9 +89,12 @@ module Glimmer
85
89
  end
86
90
 
87
91
  def native(native_type=nil, native_extra_args)
88
- puts "Generating native executable with javapackager/jpackage..."
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')
89
95
  require 'facets/string/titlecase'
90
96
  require 'facets/string/underscore'
97
+ require 'facets/string/camelcase'
91
98
  project_name = File.basename(File.expand_path('.'))
92
99
  version_file = File.expand_path('./VERSION')
93
100
  version = (File.read(version_file).strip if File.exists?(version_file) && File.file?(version_file)) rescue nil
@@ -97,7 +104,7 @@ module Glimmer
97
104
  human_name = project_name.underscore.titlecase
98
105
  icon = "package/#{OS.mac? ? 'macosx' : 'windows'}/#{human_name}.#{OS.mac? ? 'icns' : 'ico'}"
99
106
  if (`javapackager`.to_s.include?('Usage: javapackager') rescue nil)
100
- command = "javapackager -deploy -native #{native_type} -outdir packages -outfile \"#{project_name}\" -srcfiles \"dist/#{project_name}.jar\" -appclass JarMain -name \"#{human_name}\" -title \"#{human_name}\" -Bmac.CFBundleName=\"#{human_name}\" -Bmac.CFBundleIdentifier=\"org.#{project_name}.application.#{project_name}\" -Bmac.category=\"public.app-category.business\" -BinstalldirChooser=true -Bvendor=\"#{human_name}\" -Bwin.menuGroup=\"#{human_name}\" "
107
+ command = "javapackager -deploy -native #{native_type} -outdir packages -outfile \"#{project_name}\" -srcfiles \"dist/#{project_name}.jar\" -appclass JarMain -name \"#{human_name}\" -title \"#{human_name}\" -Bmac.CFBundleName=\"#{human_name}\" -Bmac.CFBundleIdentifier=\"org.#{project_name}.application.#{project_name.camelcase(:upper)}\" -Bmac.category=\"public.app-category.business\" -BinstalldirChooser=true -Bvendor=\"#{human_name}\" -Bwin.menuGroup=\"#{human_name}\" "
101
108
  command += " -BsystemWide=false " if OS.windows?
102
109
  command += " -BjvmOptions=-XstartOnFirstThread " if OS.mac?
103
110
  command += " -BappVersion=#{version} -Bmac.CFBundleVersion=#{version} " if version
@@ -121,10 +121,20 @@ module Glimmer
121
121
  MULTI_LINE_STRING
122
122
 
123
123
  def app(app_name)
124
+ common_app(app_name)
125
+ end
126
+
127
+ def desktopify(app_name, website)
128
+ common_app(app_name, :desktopify, website: website)
129
+ end
130
+
131
+ def common_app(app_name, shell_type = :app, shell_options = {})
124
132
  gem_name = file_name(app_name)
125
133
  gem_summary = human_name(app_name)
134
+ return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
126
135
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
127
136
  system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
137
+ return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
128
138
  cd gem_name
129
139
  rm_rf 'lib'
130
140
  write '.gitignore', GITIGNORE
@@ -132,13 +142,17 @@ module Glimmer
132
142
  write '.ruby-gemset', app_name
133
143
  write 'VERSION', '1.0.0'
134
144
  write 'LICENSE.txt', "Copyright (c) #{Time.now.year} #{app_name}"
135
- write 'Gemfile', GEMFILE
145
+ write 'Gemfile', gemfile(shell_type)
136
146
  write 'Rakefile', gem_rakefile(app_name, nil, gem_name)
137
147
  mkdir 'app'
138
148
  write "app/#{file_name(app_name)}.rb", app_main_file(app_name)
139
149
  mkdir 'app/models'
140
150
  mkdir 'app/views'
141
- custom_shell('AppView', current_dir_name, :app)
151
+ if shell_type == :desktopify
152
+ custom_shell('AppView', current_dir_name, shell_type, shell_options)
153
+ else
154
+ custom_shell('AppView', current_dir_name, shell_type)
155
+ end
142
156
 
143
157
  mkdir_p 'package/windows'
144
158
  icon_file = "package/windows/#{human_name(app_name)}.ico"
@@ -155,14 +169,17 @@ module Glimmer
155
169
  cp File.expand_path('../../../../icons/scaffold_app.png', __FILE__), icon_file
156
170
  puts "Created #{current_dir_name}/#{icon_file}"
157
171
 
158
- mkdir 'bin'
159
- write "bin/#{file_name(app_name)}", app_bin_file(app_name)
172
+ mkdir_p "app/#{file_name(app_name)}"
173
+ write "app/#{file_name(app_name)}/launch.rb", app_launch_file(app_name)
174
+ mkdir_p 'bin'
175
+ write "bin/#{file_name(app_name)}", app_bin_command_file(app_name)
176
+ FileUtils.chmod 0755, "bin/#{file_name(app_name)}"
160
177
  if OS.windows?
161
178
  system "bundle"
162
179
  system "rspec --init"
163
180
  else
164
- system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n rspec --init\n'"
165
- end
181
+ system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n rspec --init\n'"
182
+ end
166
183
  write 'spec/spec_helper.rb', spec_helper_file
167
184
  if OS.windows?
168
185
  system "glimmer package[image]"
@@ -172,23 +189,25 @@ module Glimmer
172
189
  if OS.mac?
173
190
  system "open packages/bundles/#{human_name(app_name).gsub(' ', '\ ')}.app"
174
191
  else
175
- system "glimmer bin/#{file_name(app_name)}"
192
+ system "glimmer run"
176
193
  end
177
- end
194
+ end
178
195
  end
179
196
 
180
- def custom_shell(custom_shell_name, namespace, shell_type = nil)
197
+ def custom_shell(custom_shell_name, namespace, shell_type = nil, shell_options = {})
181
198
  namespace ||= current_dir_name
182
199
  root_dir = File.exists?('app') ? 'app' : 'lib'
183
200
  parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
201
+ 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")
184
202
  mkdir_p parent_dir unless File.exists?(parent_dir)
185
- write "#{parent_dir}/#{file_name(custom_shell_name)}.rb", custom_shell_file(custom_shell_name, namespace, shell_type)
203
+ write "#{parent_dir}/#{file_name(custom_shell_name)}.rb", custom_shell_file(custom_shell_name, namespace, shell_type, shell_options)
186
204
  end
187
205
 
188
206
  def custom_widget(custom_widget_name, namespace)
189
207
  namespace ||= current_dir_name
190
208
  root_dir = File.exists?('app') ? 'app' : 'lib'
191
209
  parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
210
+ 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")
192
211
  mkdir_p parent_dir unless File.exists?(parent_dir)
193
212
  write "#{parent_dir}/#{file_name(custom_widget_name)}.rb", custom_widget_file(custom_widget_name, namespace)
194
213
  end
@@ -210,8 +229,10 @@ module Glimmer
210
229
  return puts('Namespace is required! Usage: glimmer scaffold:gem:customshell[name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
211
230
  namespace = 'glimmer'
212
231
  end
232
+ return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
213
233
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
214
234
  system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
235
+ return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
215
236
  cd gem_name
216
237
  write '.gitignore', GITIGNORE
217
238
  write '.ruby-version', RUBY_VERSION
@@ -222,9 +243,13 @@ module Glimmer
222
243
  append "lib/#{gem_name}.rb", gem_main_file(custom_shell_name, namespace)
223
244
  mkdir 'lib/views'
224
245
  custom_shell(custom_shell_name, namespace, :gem)
225
- mkdir 'bin'
226
- write "bin/#{gem_name}", gem_bin_file(gem_name, custom_shell_name, namespace)
227
- write "bin/#{file_name(custom_shell_name)}", gem_bin_command_file(gem_name)
246
+
247
+ mkdir_p "lib/#{file_name(namespace)}/#{file_name(custom_shell_name)}"
248
+ write "lib/#{file_name(namespace)}/#{file_name(custom_shell_name)}/launch.rb", gem_launch_file(gem_name, custom_shell_name, namespace)
249
+ mkdir_p 'bin'
250
+ write "bin/#{gem_name}", gem_bin_command_file(gem_name, custom_shell_name, namespace)
251
+ FileUtils.chmod 0755, "bin/#{gem_name}"
252
+ write "bin/#{file_name(custom_shell_name)}", gem_bin_command_file(gem_name, custom_shell_name, namespace)
228
253
  FileUtils.chmod 0755, "bin/#{file_name(custom_shell_name)}"
229
254
  if OS.windows?
230
255
  system "bundle"
@@ -257,7 +282,7 @@ module Glimmer
257
282
  if OS.mac?
258
283
  system "open packages/bundles/#{human_name(custom_shell_name).gsub(' ', '\ ')}.app" if OS.mac?
259
284
  else
260
- system "bin/#{file_name(custom_shell_name)}"
285
+ system "glimmer run"
261
286
  end
262
287
  end
263
288
  puts "Finished creating #{gem_name} Ruby gem."
@@ -278,8 +303,10 @@ module Glimmer
278
303
  namespace = 'glimmer'
279
304
  end
280
305
 
306
+ return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
281
307
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
282
308
  system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
309
+ return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
283
310
  cd gem_name
284
311
  write '.gitignore', GITIGNORE
285
312
  write '.ruby-version', RUBY_VERSION
@@ -342,6 +369,22 @@ module Glimmer
342
369
  def compact_name(gem_name)
343
370
  gem_name.underscore.camelcase.downcase
344
371
  end
372
+
373
+ def gemfile(shell_type)
374
+ if shell_type == :desktopify
375
+ lines = GEMFILE.split("\n")
376
+ require_glimmer_dsl_swt_index = lines.index(lines.detect {|l| l.include?("gem 'glimmer-dsl-swt'") })
377
+ lines[(require_glimmer_dsl_swt_index + 1)..(require_glimmer_dsl_swt_index + 1)] = [
378
+ "",
379
+ "# Enable Chromium Browser Glimmer Custom Widget gem if needed (e.g. Linux needs it to support HTML5 Video), and use `browser(:chromium)` in GUI.",
380
+ "# gem 'glimmer-cw-browser-chromium', '>= 0'",
381
+ "",
382
+ ]
383
+ lines.join("\n")
384
+ else
385
+ GEMFILE
386
+ end
387
+ end
345
388
 
346
389
  def app_main_file(app_name)
347
390
  <<~MULTI_LINE_STRING
@@ -378,40 +421,68 @@ module Glimmer
378
421
  MULTI_LINE_STRING
379
422
  end
380
423
 
381
- def app_bin_file(app_name)
424
+ def app_launch_file(app_name)
382
425
  <<~MULTI_LINE_STRING
383
- require_relative '../app/#{file_name(app_name)}'
426
+ require_relative '../#{file_name(app_name)}'
384
427
 
385
428
  #{class_name(app_name)}.new.open
386
429
  MULTI_LINE_STRING
387
430
  end
388
431
 
389
- def gem_bin_file(gem_name, custom_shell_name, namespace)
390
- # TODO change this so that it does not mix Glimmer unto the main object
432
+ def app_bin_command_file(app_name)
391
433
  <<~MULTI_LINE_STRING
392
- require_relative '../lib/#{gem_name}'
434
+ #!/usr/bin/env jruby
393
435
 
394
- class #{class_name(custom_shell_name)}App
395
- include Glimmer
436
+ runner = File.expand_path("../../app/#{file_name(app_name)}/launch.rb", __FILE__)
396
437
 
397
- def open
398
- #{dsl_widget_name(custom_shell_name)}.open
438
+ # Detect if inside a JAR file or not
439
+ if runner.include?('uri:classloader')
440
+ require runner
441
+ else
442
+ require 'glimmer/launcher'
443
+
444
+ launcher = Glimmer::Launcher.new([runner] + ARGV)
445
+ launcher.launch
446
+ end
447
+ MULTI_LINE_STRING
448
+ end
449
+
450
+ def gem_launch_file(gem_name, custom_shell_name, namespace)
451
+ # TODO change this so that it does not mix Glimmer unto the main object
452
+ <<~MULTI_LINE_STRING
453
+ require_relative '../../#{gem_name}'
454
+
455
+ module #{class_name(namespace)}
456
+ class #{class_name(custom_shell_name)}
457
+ class App
458
+ include Glimmer
459
+
460
+ def open
461
+ #{dsl_widget_name(custom_shell_name)}.open
462
+ end
463
+ end
399
464
  end
400
465
  end
401
466
 
402
- #{class_name(custom_shell_name)}App.new.open
467
+ #{class_name(namespace)}::#{class_name(custom_shell_name)}::App.new.open
403
468
  MULTI_LINE_STRING
404
469
  end
405
470
 
406
- def gem_bin_command_file(gem_name)
471
+ def gem_bin_command_file(gem_name, custom_shell_name, namespace)
407
472
  <<~MULTI_LINE_STRING
408
473
  #!/usr/bin/env jruby
409
474
 
410
- require 'glimmer/launcher'
475
+ runner = File.expand_path("../../lib/#{file_name(namespace)}/#{file_name(custom_shell_name)}/launch.rb", __FILE__)
411
476
 
412
- runner = File.expand_path("../#{gem_name}", __FILE__)
413
- launcher = Glimmer::Launcher.new([runner] + ARGV)
414
- launcher.launch
477
+ # Detect if inside a JAR file or not
478
+ if runner.include?('uri:classloader')
479
+ require runner
480
+ else
481
+ require 'glimmer/launcher'
482
+
483
+ launcher = Glimmer::Launcher.new([runner] + ARGV)
484
+ launcher.launch
485
+ end
415
486
  MULTI_LINE_STRING
416
487
  end
417
488
 
@@ -422,7 +493,8 @@ module Glimmer
422
493
  lines.insert(require_rake_line_index, "require 'glimmer/launcher'")
423
494
  gem_files_line_index = lines.index(lines.detect {|l| l.include?('# dependencies defined in Gemfile') })
424
495
  if custom_shell_name
425
- lines.insert(gem_files_line_index, " gem.files = Dir['VERSION', 'LICENSE.txt', 'lib/**/*', 'app/**/*', 'bin/**/*', 'vendor/**/*', 'package/**/*']")
496
+ 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/**/*']")
497
+ # 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)
426
498
  lines.insert(gem_files_line_index+1, " gem.executables = ['#{gem_name}', '#{file_name(custom_shell_name)}']")
427
499
  lines.insert(gem_files_line_index+2, " gem.require_paths = ['vendor', 'lib', 'app']")
428
500
  else
@@ -438,7 +510,7 @@ module Glimmer
438
510
  " -name '#{human_name(custom_shell_name)}'" +
439
511
  " -title '#{human_name(custom_shell_name)}'" +
440
512
  " -Bmac.CFBundleName='#{human_name(custom_shell_name)}'" +
441
- " -Bmac.CFBundleIdentifier='org.#{namespace ? compact_name(namespace) : compact_name(custom_shell_name)}.application.#{compact_name(custom_shell_name).capitalize}'"
513
+ " -Bmac.CFBundleIdentifier='org.#{namespace ? compact_name(namespace) : compact_name(custom_shell_name)}.application.#{compact_name(custom_shell_name).camelcase(:upper)}'"
442
514
  # " -BlicenseType=" +
443
515
  # " -Bmac.category=" +
444
516
  # " -Bmac.signing-key-developer-id-app="
@@ -468,7 +540,7 @@ module Glimmer
468
540
  lines.join("\n")
469
541
  end
470
542
 
471
- def custom_shell_file(custom_shell_name, namespace, shell_type)
543
+ def custom_shell_file(custom_shell_name, namespace, shell_type, shell_options = {})
472
544
  namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
473
545
 
474
546
  custom_shell_file_content = <<-MULTI_LINE_STRING
@@ -493,14 +565,14 @@ module Glimmer
493
565
  # options :title, :background_color
494
566
  # option :width, default: 320
495
567
  # option :height, default: 240
496
- option :greeting, default: 'Hello, World!'
568
+ #{'# ' if shell_type == :desktopify}option :greeting, default: 'Hello, World!'
497
569
 
498
570
  ## Use before_body block to pre-initialize variables to use in body
499
571
  #
500
572
  #
501
573
  MULTI_LINE_STRING
502
574
 
503
- if %i[gem app].include?(shell_type)
575
+ if %i[gem app desktopify].include?(shell_type)
504
576
  custom_shell_file_content += <<-MULTI_LINE_STRING
505
577
  before_body {
506
578
  Display.setAppName('#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}')
@@ -510,7 +582,7 @@ module Glimmer
510
582
  display_about_dialog
511
583
  }
512
584
  on_preferences {
513
- display_preferences_dialog
585
+ #{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
514
586
  }
515
587
  }
516
588
  }
@@ -537,40 +609,72 @@ module Glimmer
537
609
  body {
538
610
  shell {
539
611
  # Replace example content below with custom shell content
540
- minimum_size 320, 240
612
+ minimum_size #{shell_type == :desktopify ? '1024, 768' : '320, 240'}
541
613
  image File.join(APP_ROOT, 'package', 'windows', "#{human_name(shell_type == :gem ? custom_shell_name : current_dir_name)}.ico") if OS.windows?
542
614
  text "#{human_name(namespace)} - #{human_name(custom_shell_name)}"
615
+
616
+ MULTI_LINE_STRING
617
+
618
+ if shell_type == :desktopify
619
+ custom_shell_file_content += <<-MULTI_LINE_STRING
620
+ browser {
621
+ url "#{shell_options[:website]}"
622
+ }
623
+ MULTI_LINE_STRING
624
+ else
625
+ custom_shell_file_content += <<-MULTI_LINE_STRING
543
626
  grid_layout
544
627
  label(:center) {
545
628
  text bind(self, :greeting)
546
629
  font height: 40
547
630
  layout_data :fill, :center, true, true
548
- }
631
+ }
632
+ MULTI_LINE_STRING
633
+ end
634
+
635
+ if %i[gem app desktopify].include?(shell_type)
636
+ custom_shell_file_content += <<-MULTI_LINE_STRING
637
+
549
638
  menu_bar {
550
639
  menu {
551
640
  text '&File'
641
+ menu_item {
642
+ text '&About...'
643
+ on_widget_selected {
644
+ display_about_dialog
645
+ }
646
+ }
552
647
  menu_item {
553
648
  text '&Preferences...'
554
649
  on_widget_selected {
555
- display_preferences_dialog
650
+ #{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
556
651
  }
557
652
  }
558
653
  }
559
654
  }
655
+ MULTI_LINE_STRING
656
+ end
657
+
658
+ custom_shell_file_content += <<-MULTI_LINE_STRING
560
659
  }
561
660
  }
562
- MULTI_LINE_STRING
563
-
564
- if %i[gem app].include?(shell_type)
661
+ MULTI_LINE_STRING
662
+
663
+ if %i[gem app desktopify].include?(shell_type)
565
664
  custom_shell_file_content += <<-MULTI_LINE_STRING
566
665
 
567
666
  def display_about_dialog
568
667
  message_box(body_root) {
569
668
  text 'About'
570
- message "#{human_name(namespace)} - #{human_name(custom_shell_name)} \#{VERSION}\\n\\n\#{LICENSE}"
669
+ message "#{human_name(namespace)}#{" - #{human_name(custom_shell_name)}" if shell_type == :gem} \#{VERSION}\\n\\n\#{LICENSE}"
571
670
  }.open
572
671
  end
573
672
 
673
+ MULTI_LINE_STRING
674
+ end
675
+
676
+ if %i[gem app].include?(shell_type)
677
+ custom_shell_file_content += <<-MULTI_LINE_STRING
574
678
  def display_preferences_dialog
575
679
  dialog(swt_widget) {
576
680
  text 'Preferences'