glimmer-dsl-swt 4.17.2.4 → 4.17.5.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/README.md +294 -467
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +14 -6
- data/lib/glimmer-dsl-swt.rb +1 -0
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -0
- data/lib/glimmer/dsl/swt/expand_item_expression.rb +60 -0
- data/lib/glimmer/dsl/swt/widget_expression.rb +2 -0
- data/lib/glimmer/rake_task.rb +19 -21
- data/lib/glimmer/rake_task/package.rb +9 -2
- data/lib/glimmer/rake_task/scaffold.rb +138 -42
- data/lib/glimmer/swt/custom/code_text.rb +95 -0
- data/lib/glimmer/swt/expand_item_proxy.rb +98 -0
- data/lib/glimmer/swt/image_proxy.rb +5 -0
- data/lib/glimmer/swt/message_box_proxy.rb +1 -1
- data/lib/glimmer/swt/sash_form_proxy.rb +53 -0
- data/lib/glimmer/swt/styled_text_proxy.rb +43 -0
- data/lib/glimmer/swt/tab_item_proxy.rb +1 -1
- data/lib/glimmer/swt/widget_proxy.rb +92 -33
- data/samples/elaborate/meta_sample.rb +166 -0
- data/samples/hello/hello_expand_bar.rb +108 -0
- data/samples/hello/hello_sash_form.rb +137 -0
- data/samples/hello/hello_styled_text.rb +138 -0
- metadata +16 -8
- data/lib/glimmer/rake_task/sample.rb +0 -115
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.17.
|
1
|
+
4.17.5.0
|
data/glimmer-dsl-swt.gemspec
CHANGED
@@ -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.
|
5
|
+
# stub: glimmer-dsl-swt 4.17.5.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-dsl-swt".freeze
|
9
|
-
s.version = "4.17.
|
9
|
+
s.version = "4.17.5.0"
|
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-
|
14
|
+
s.date = "2020-10-24"
|
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]
|
@@ -56,6 +56,7 @@ Gem::Specification.new do |s|
|
|
56
56
|
"lib/glimmer/dsl/swt/dnd_expression.rb",
|
57
57
|
"lib/glimmer/dsl/swt/dsl.rb",
|
58
58
|
"lib/glimmer/dsl/swt/exec_expression.rb",
|
59
|
+
"lib/glimmer/dsl/swt/expand_item_expression.rb",
|
59
60
|
"lib/glimmer/dsl/swt/font_expression.rb",
|
60
61
|
"lib/glimmer/dsl/swt/image_expression.rb",
|
61
62
|
"lib/glimmer/dsl/swt/layout_data_expression.rb",
|
@@ -81,12 +82,13 @@ Gem::Specification.new do |s|
|
|
81
82
|
"lib/glimmer/rake_task.rb",
|
82
83
|
"lib/glimmer/rake_task/list.rb",
|
83
84
|
"lib/glimmer/rake_task/package.rb",
|
84
|
-
"lib/glimmer/rake_task/sample.rb",
|
85
85
|
"lib/glimmer/rake_task/scaffold.rb",
|
86
86
|
"lib/glimmer/swt/color_proxy.rb",
|
87
87
|
"lib/glimmer/swt/cursor_proxy.rb",
|
88
|
+
"lib/glimmer/swt/custom/code_text.rb",
|
88
89
|
"lib/glimmer/swt/display_proxy.rb",
|
89
90
|
"lib/glimmer/swt/dnd_proxy.rb",
|
91
|
+
"lib/glimmer/swt/expand_item_proxy.rb",
|
90
92
|
"lib/glimmer/swt/font_proxy.rb",
|
91
93
|
"lib/glimmer/swt/image_proxy.rb",
|
92
94
|
"lib/glimmer/swt/layout_data_proxy.rb",
|
@@ -94,9 +96,11 @@ Gem::Specification.new do |s|
|
|
94
96
|
"lib/glimmer/swt/menu_proxy.rb",
|
95
97
|
"lib/glimmer/swt/message_box_proxy.rb",
|
96
98
|
"lib/glimmer/swt/packages.rb",
|
99
|
+
"lib/glimmer/swt/sash_form_proxy.rb",
|
97
100
|
"lib/glimmer/swt/scrolled_composite_proxy.rb",
|
98
101
|
"lib/glimmer/swt/shell_proxy.rb",
|
99
102
|
"lib/glimmer/swt/style_constantizable.rb",
|
103
|
+
"lib/glimmer/swt/styled_text_proxy.rb",
|
100
104
|
"lib/glimmer/swt/swt_proxy.rb",
|
101
105
|
"lib/glimmer/swt/tab_item_proxy.rb",
|
102
106
|
"lib/glimmer/swt/table_column_proxy.rb",
|
@@ -112,6 +116,7 @@ Gem::Specification.new do |s|
|
|
112
116
|
"samples/elaborate/contact_manager/contact_manager_presenter.rb",
|
113
117
|
"samples/elaborate/contact_manager/contact_repository.rb",
|
114
118
|
"samples/elaborate/login.rb",
|
119
|
+
"samples/elaborate/meta_sample.rb",
|
115
120
|
"samples/elaborate/tic_tac_toe.rb",
|
116
121
|
"samples/elaborate/tic_tac_toe/board.rb",
|
117
122
|
"samples/elaborate/tic_tac_toe/cell.rb",
|
@@ -123,11 +128,14 @@ Gem::Specification.new do |s|
|
|
123
128
|
"samples/hello/hello_custom_shell.rb",
|
124
129
|
"samples/hello/hello_custom_widget.rb",
|
125
130
|
"samples/hello/hello_drag_and_drop.rb",
|
131
|
+
"samples/hello/hello_expand_bar.rb",
|
126
132
|
"samples/hello/hello_list_multi_selection.rb",
|
127
133
|
"samples/hello/hello_list_single_selection.rb",
|
128
134
|
"samples/hello/hello_menu_bar.rb",
|
129
135
|
"samples/hello/hello_message_box.rb",
|
130
136
|
"samples/hello/hello_pop_up_context_menu.rb",
|
137
|
+
"samples/hello/hello_sash_form.rb",
|
138
|
+
"samples/hello/hello_styled_text.rb",
|
131
139
|
"samples/hello/hello_tab.rb",
|
132
140
|
"samples/hello/hello_world.rb",
|
133
141
|
"vendor/swt/linux/swt.jar",
|
@@ -155,7 +163,7 @@ Gem::Specification.new do |s|
|
|
155
163
|
s.add_runtime_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
|
156
164
|
s.add_runtime_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
|
157
165
|
s.add_runtime_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
|
158
|
-
s.add_runtime_dependency(%q<
|
166
|
+
s.add_runtime_dependency(%q<rouge>.freeze, [">= 3.23.0", "< 4.0.0"])
|
159
167
|
s.add_development_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
|
160
168
|
s.add_development_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
|
161
169
|
s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
|
@@ -174,7 +182,7 @@ Gem::Specification.new do |s|
|
|
174
182
|
s.add_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
|
175
183
|
s.add_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
|
176
184
|
s.add_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
|
177
|
-
s.add_dependency(%q<
|
185
|
+
s.add_dependency(%q<rouge>.freeze, [">= 3.23.0", "< 4.0.0"])
|
178
186
|
s.add_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
|
179
187
|
s.add_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
|
180
188
|
s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
|
data/lib/glimmer-dsl-swt.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Copyright (c) 2007-2020 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/expand_item_proxy'
|
27
|
+
|
28
|
+
module Glimmer
|
29
|
+
module DSL
|
30
|
+
module SWT
|
31
|
+
class ExpandItemExpression < StaticExpression
|
32
|
+
include ParentExpression
|
33
|
+
|
34
|
+
include_package 'org.eclipse.swt.widgets'
|
35
|
+
|
36
|
+
def can_interpret?(parent, keyword, *args, &block)
|
37
|
+
initial_condition = (keyword == 'expand_item') and parent.respond_to?(:swt_widget)
|
38
|
+
if initial_condition
|
39
|
+
if parent.swt_widget.is_a?(ExpandBar)
|
40
|
+
return true
|
41
|
+
else
|
42
|
+
Glimmer::Config.logger.error {"expand_item widget may only be used directly under a expand_bar widget!"}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
48
|
+
def interpret(parent, keyword, *args, &block)
|
49
|
+
Glimmer::SWT::ExpandItemProxy.new(parent, args)
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_content(parent, &block)
|
53
|
+
super
|
54
|
+
parent.post_add_content
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/glimmer/rake_task.rb
CHANGED
@@ -62,26 +62,9 @@ namespace :glimmer do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
desc 'Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples.'
|
71
|
-
task :run, [:name] => [:requires] do |t, args|
|
72
|
-
Glimmer::RakeTask::Sample.run(args[:name])
|
73
|
-
end
|
74
|
-
|
75
|
-
desc 'Lists Glimmer internal samples [included in gem]. Filters by query if specified (query is optional)'
|
76
|
-
task :list, [:query] => [:requires] do |t, args|
|
77
|
-
Glimmer::RakeTask::Sample.list(args[:query])
|
78
|
-
end
|
79
|
-
|
80
|
-
desc 'Outputs code for a Glimmer internal sample [included in gem] (name is required)'
|
81
|
-
task :code, [:name] => [:requires] do |t, args|
|
82
|
-
Glimmer::RakeTask::Sample.code(args[:name])
|
83
|
-
end
|
84
|
-
|
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
|
85
68
|
end
|
86
69
|
|
87
70
|
namespace :package do
|
@@ -95,6 +78,11 @@ namespace :glimmer do
|
|
95
78
|
Glimmer::RakeTask::Package.gemspec
|
96
79
|
end
|
97
80
|
|
81
|
+
desc 'Generate gem under pkg directory'
|
82
|
+
task :gem do
|
83
|
+
Glimmer::RakeTask::Package.gem
|
84
|
+
end
|
85
|
+
|
98
86
|
desc 'Generate JAR config file'
|
99
87
|
task :config do
|
100
88
|
Glimmer::RakeTask::Package.config
|
@@ -123,7 +111,11 @@ namespace :glimmer do
|
|
123
111
|
Rake::Task['glimmer:package:lock_jars'].execute
|
124
112
|
Rake::Task['glimmer:package:config'].execute
|
125
113
|
Rake::Task['glimmer:package:jar'].execute
|
126
|
-
|
114
|
+
if OS.linux?
|
115
|
+
Rake::Task['glimmer:package:gem'].execute
|
116
|
+
else
|
117
|
+
Rake::Task['glimmer:package:native'].execute(args)
|
118
|
+
end
|
127
119
|
end
|
128
120
|
|
129
121
|
desc 'Scaffold Glimmer application directory structure to build a new app'
|
@@ -153,6 +145,12 @@ namespace :glimmer do
|
|
153
145
|
task :custom_widget, [:name, :namespace] => :customwidget
|
154
146
|
task :"custom-widget", [:name, :namespace] => :customwidget
|
155
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
|
+
|
156
154
|
namespace :gem do
|
157
155
|
desc 'Scaffold Glimmer::UI::CustomShell subclass (full window view) under its own Ruby gem + app project (namespace is required) [alt: scaffold:gem:cs]'
|
158
156
|
task :customshell, [:name, :namespace] do |t, args|
|
@@ -39,6 +39,10 @@ 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
47
|
puts 'Locking gem jar-dependencies by downloading and storing in vendor/jars...'
|
44
48
|
FileUtils.mkdir_p('vendor/jars')
|
@@ -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,6 +121,14 @@ 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)
|
126
134
|
return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
|
@@ -134,13 +142,17 @@ module Glimmer
|
|
134
142
|
write '.ruby-gemset', app_name
|
135
143
|
write 'VERSION', '1.0.0'
|
136
144
|
write 'LICENSE.txt', "Copyright (c) #{Time.now.year} #{app_name}"
|
137
|
-
write 'Gemfile',
|
145
|
+
write 'Gemfile', gemfile(shell_type)
|
138
146
|
write 'Rakefile', gem_rakefile(app_name, nil, gem_name)
|
139
147
|
mkdir 'app'
|
140
148
|
write "app/#{file_name(app_name)}.rb", app_main_file(app_name)
|
141
149
|
mkdir 'app/models'
|
142
150
|
mkdir 'app/views'
|
143
|
-
|
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
|
144
156
|
|
145
157
|
mkdir_p 'package/windows'
|
146
158
|
icon_file = "package/windows/#{human_name(app_name)}.ico"
|
@@ -157,14 +169,17 @@ module Glimmer
|
|
157
169
|
cp File.expand_path('../../../../icons/scaffold_app.png', __FILE__), icon_file
|
158
170
|
puts "Created #{current_dir_name}/#{icon_file}"
|
159
171
|
|
160
|
-
|
161
|
-
write "
|
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)}"
|
162
177
|
if OS.windows?
|
163
178
|
system "bundle"
|
164
179
|
system "rspec --init"
|
165
180
|
else
|
166
|
-
system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n rspec --init\n'"
|
167
|
-
end
|
181
|
+
system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n rspec --init\n'"
|
182
|
+
end
|
168
183
|
write 'spec/spec_helper.rb', spec_helper_file
|
169
184
|
if OS.windows?
|
170
185
|
system "glimmer package[image]"
|
@@ -174,18 +189,18 @@ module Glimmer
|
|
174
189
|
if OS.mac?
|
175
190
|
system "open packages/bundles/#{human_name(app_name).gsub(' ', '\ ')}.app"
|
176
191
|
else
|
177
|
-
system "glimmer
|
192
|
+
system "glimmer run"
|
178
193
|
end
|
179
|
-
end
|
194
|
+
end
|
180
195
|
end
|
181
196
|
|
182
|
-
def custom_shell(custom_shell_name, namespace, shell_type = nil)
|
197
|
+
def custom_shell(custom_shell_name, namespace, shell_type = nil, shell_options = {})
|
183
198
|
namespace ||= current_dir_name
|
184
199
|
root_dir = File.exists?('app') ? 'app' : 'lib'
|
185
200
|
parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
|
186
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")
|
187
202
|
mkdir_p parent_dir unless File.exists?(parent_dir)
|
188
|
-
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)
|
189
204
|
end
|
190
205
|
|
191
206
|
def custom_widget(custom_widget_name, namespace)
|
@@ -228,9 +243,13 @@ module Glimmer
|
|
228
243
|
append "lib/#{gem_name}.rb", gem_main_file(custom_shell_name, namespace)
|
229
244
|
mkdir 'lib/views'
|
230
245
|
custom_shell(custom_shell_name, namespace, :gem)
|
231
|
-
|
232
|
-
|
233
|
-
write "
|
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)
|
234
253
|
FileUtils.chmod 0755, "bin/#{file_name(custom_shell_name)}"
|
235
254
|
if OS.windows?
|
236
255
|
system "bundle"
|
@@ -263,7 +282,7 @@ module Glimmer
|
|
263
282
|
if OS.mac?
|
264
283
|
system "open packages/bundles/#{human_name(custom_shell_name).gsub(' ', '\ ')}.app" if OS.mac?
|
265
284
|
else
|
266
|
-
system "
|
285
|
+
system "glimmer run"
|
267
286
|
end
|
268
287
|
end
|
269
288
|
puts "Finished creating #{gem_name} Ruby gem."
|
@@ -350,6 +369,22 @@ module Glimmer
|
|
350
369
|
def compact_name(gem_name)
|
351
370
|
gem_name.underscore.camelcase.downcase
|
352
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
|
353
388
|
|
354
389
|
def app_main_file(app_name)
|
355
390
|
<<~MULTI_LINE_STRING
|
@@ -386,40 +421,68 @@ module Glimmer
|
|
386
421
|
MULTI_LINE_STRING
|
387
422
|
end
|
388
423
|
|
389
|
-
def
|
424
|
+
def app_launch_file(app_name)
|
390
425
|
<<~MULTI_LINE_STRING
|
391
|
-
require_relative '
|
426
|
+
require_relative '../#{file_name(app_name)}'
|
392
427
|
|
393
428
|
#{class_name(app_name)}.new.open
|
394
429
|
MULTI_LINE_STRING
|
395
430
|
end
|
396
431
|
|
397
|
-
def
|
398
|
-
# TODO change this so that it does not mix Glimmer unto the main object
|
432
|
+
def app_bin_command_file(app_name)
|
399
433
|
<<~MULTI_LINE_STRING
|
400
|
-
|
434
|
+
#!/usr/bin/env jruby
|
401
435
|
|
402
|
-
|
403
|
-
include Glimmer
|
436
|
+
runner = File.expand_path("../../app/#{file_name(app_name)}/launch.rb", __FILE__)
|
404
437
|
|
405
|
-
|
406
|
-
|
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
|
407
464
|
end
|
408
465
|
end
|
409
466
|
|
410
|
-
#{class_name(custom_shell_name)}App.new.open
|
467
|
+
#{class_name(namespace)}::#{class_name(custom_shell_name)}::App.new.open
|
411
468
|
MULTI_LINE_STRING
|
412
469
|
end
|
413
470
|
|
414
|
-
def gem_bin_command_file(gem_name)
|
471
|
+
def gem_bin_command_file(gem_name, custom_shell_name, namespace)
|
415
472
|
<<~MULTI_LINE_STRING
|
416
473
|
#!/usr/bin/env jruby
|
417
474
|
|
418
|
-
|
475
|
+
runner = File.expand_path("../../lib/#{file_name(namespace)}/#{file_name(custom_shell_name)}/launch.rb", __FILE__)
|
419
476
|
|
420
|
-
|
421
|
-
|
422
|
-
|
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
|
423
486
|
MULTI_LINE_STRING
|
424
487
|
end
|
425
488
|
|
@@ -430,7 +493,8 @@ module Glimmer
|
|
430
493
|
lines.insert(require_rake_line_index, "require 'glimmer/launcher'")
|
431
494
|
gem_files_line_index = lines.index(lines.detect {|l| l.include?('# dependencies defined in Gemfile') })
|
432
495
|
if custom_shell_name
|
433
|
-
lines.insert(gem_files_line_index, " gem.files = Dir['VERSION', 'LICENSE.txt', 'lib/**/*', '
|
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)
|
434
498
|
lines.insert(gem_files_line_index+1, " gem.executables = ['#{gem_name}', '#{file_name(custom_shell_name)}']")
|
435
499
|
lines.insert(gem_files_line_index+2, " gem.require_paths = ['vendor', 'lib', 'app']")
|
436
500
|
else
|
@@ -446,7 +510,7 @@ module Glimmer
|
|
446
510
|
" -name '#{human_name(custom_shell_name)}'" +
|
447
511
|
" -title '#{human_name(custom_shell_name)}'" +
|
448
512
|
" -Bmac.CFBundleName='#{human_name(custom_shell_name)}'" +
|
449
|
-
" -Bmac.CFBundleIdentifier='org.#{namespace ? compact_name(namespace) : compact_name(custom_shell_name)}.application.#{compact_name(custom_shell_name).
|
513
|
+
" -Bmac.CFBundleIdentifier='org.#{namespace ? compact_name(namespace) : compact_name(custom_shell_name)}.application.#{compact_name(custom_shell_name).camelcase(:upper)}'"
|
450
514
|
# " -BlicenseType=" +
|
451
515
|
# " -Bmac.category=" +
|
452
516
|
# " -Bmac.signing-key-developer-id-app="
|
@@ -476,7 +540,7 @@ module Glimmer
|
|
476
540
|
lines.join("\n")
|
477
541
|
end
|
478
542
|
|
479
|
-
def custom_shell_file(custom_shell_name, namespace, shell_type)
|
543
|
+
def custom_shell_file(custom_shell_name, namespace, shell_type, shell_options = {})
|
480
544
|
namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
|
481
545
|
|
482
546
|
custom_shell_file_content = <<-MULTI_LINE_STRING
|
@@ -501,14 +565,14 @@ module Glimmer
|
|
501
565
|
# options :title, :background_color
|
502
566
|
# option :width, default: 320
|
503
567
|
# option :height, default: 240
|
504
|
-
option :greeting, default: 'Hello, World!'
|
568
|
+
#{'# ' if shell_type == :desktopify}option :greeting, default: 'Hello, World!'
|
505
569
|
|
506
570
|
## Use before_body block to pre-initialize variables to use in body
|
507
571
|
#
|
508
572
|
#
|
509
573
|
MULTI_LINE_STRING
|
510
574
|
|
511
|
-
if %i[gem app].include?(shell_type)
|
575
|
+
if %i[gem app desktopify].include?(shell_type)
|
512
576
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
513
577
|
before_body {
|
514
578
|
Display.setAppName('#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}')
|
@@ -518,7 +582,7 @@ module Glimmer
|
|
518
582
|
display_about_dialog
|
519
583
|
}
|
520
584
|
on_preferences {
|
521
|
-
display_preferences_dialog
|
585
|
+
#{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
|
522
586
|
}
|
523
587
|
}
|
524
588
|
}
|
@@ -545,40 +609,72 @@ module Glimmer
|
|
545
609
|
body {
|
546
610
|
shell {
|
547
611
|
# Replace example content below with custom shell content
|
548
|
-
minimum_size 320, 240
|
612
|
+
minimum_size #{shell_type == :desktopify ? '1024, 768' : '320, 240'}
|
549
613
|
image File.join(APP_ROOT, 'package', 'windows', "#{human_name(shell_type == :gem ? custom_shell_name : current_dir_name)}.ico") if OS.windows?
|
550
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
|
551
626
|
grid_layout
|
552
627
|
label(:center) {
|
553
628
|
text bind(self, :greeting)
|
554
629
|
font height: 40
|
555
630
|
layout_data :fill, :center, true, true
|
556
|
-
}
|
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
|
+
|
557
638
|
menu_bar {
|
558
639
|
menu {
|
559
640
|
text '&File'
|
641
|
+
menu_item {
|
642
|
+
text '&About...'
|
643
|
+
on_widget_selected {
|
644
|
+
display_about_dialog
|
645
|
+
}
|
646
|
+
}
|
560
647
|
menu_item {
|
561
648
|
text '&Preferences...'
|
562
649
|
on_widget_selected {
|
563
|
-
display_preferences_dialog
|
650
|
+
#{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
|
564
651
|
}
|
565
652
|
}
|
566
653
|
}
|
567
654
|
}
|
655
|
+
MULTI_LINE_STRING
|
656
|
+
end
|
657
|
+
|
658
|
+
custom_shell_file_content += <<-MULTI_LINE_STRING
|
568
659
|
}
|
569
660
|
}
|
570
|
-
|
571
|
-
|
572
|
-
if %i[gem app].include?(shell_type)
|
661
|
+
MULTI_LINE_STRING
|
662
|
+
|
663
|
+
if %i[gem app desktopify].include?(shell_type)
|
573
664
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
574
665
|
|
575
666
|
def display_about_dialog
|
576
667
|
message_box(body_root) {
|
577
668
|
text 'About'
|
578
|
-
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}"
|
579
670
|
}.open
|
580
671
|
end
|
581
672
|
|
673
|
+
MULTI_LINE_STRING
|
674
|
+
end
|
675
|
+
|
676
|
+
if %i[gem app].include?(shell_type)
|
677
|
+
custom_shell_file_content += <<-MULTI_LINE_STRING
|
582
678
|
def display_preferences_dialog
|
583
679
|
dialog(swt_widget) {
|
584
680
|
text 'Preferences'
|