glimmer-dsl-swt 4.18.7.6 → 4.20.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/README.md +34 -21
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/bin/girb +10 -9
- data/bin/girb_runner.rb +8 -3
- data/bin/glimmer +10 -1
- data/bin/glimmer-setup +58 -0
- data/bin/glimmer_runner.rb +4 -0
- data/docs/reference/GLIMMER_COMMAND.md +19 -30
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +39 -10
- data/docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md +7 -1
- data/docs/reference/GLIMMER_SAMPLES.md +27 -0
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer-dsl-swt.rb +8 -0
- data/lib/glimmer/data_binding/shine.rb +41 -26
- data/lib/glimmer/data_binding/widget_binding.rb +1 -1
- data/lib/glimmer/dsl/swt/c_tab_item_expression.rb +58 -0
- data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +2 -1
- data/lib/glimmer/dsl/swt/dsl.rb +2 -1
- data/lib/glimmer/dsl/swt/shine_data_binding_expression.rb +49 -0
- data/lib/glimmer/dsl/swt/tab_item_expression.rb +7 -3
- data/lib/glimmer/dsl/swt/widget_expression.rb +1 -1
- data/lib/glimmer/launcher.rb +33 -51
- data/lib/glimmer/rake_task.rb +1 -1
- data/lib/glimmer/rake_task/package.rb +7 -2
- data/lib/glimmer/rake_task/scaffold.rb +227 -254
- data/lib/glimmer/swt/c_tab_item_proxy.rb +53 -0
- data/lib/glimmer/swt/custom/code_text.rb +17 -9
- data/lib/glimmer/swt/custom/shape.rb +15 -1
- data/lib/glimmer/swt/sash_form_proxy.rb +6 -0
- data/lib/glimmer/swt/shell_proxy.rb +3 -1
- data/lib/glimmer/swt/tab_folder_proxy.rb +1 -0
- data/lib/glimmer/swt/tab_item_proxy.rb +17 -18
- data/lib/glimmer/swt/widget_proxy.rb +9 -0
- data/samples/elaborate/contact_manager.rb +7 -5
- data/samples/elaborate/login.rb +7 -7
- data/samples/elaborate/mandelbrot_fractal.rb +13 -8
- data/samples/elaborate/meta_sample.rb +4 -2
- data/samples/elaborate/metronome.rb +4 -4
- data/samples/elaborate/stock_ticker.rb +2 -2
- data/samples/elaborate/tic_tac_toe.rb +2 -2
- data/samples/hello/hello_button.rb +1 -1
- data/samples/hello/hello_c_combo.rb +69 -0
- data/samples/hello/hello_c_tab.rb +174 -0
- data/samples/hello/hello_c_tab/denmark.png +0 -0
- data/samples/hello/hello_c_tab/finland.png +0 -0
- data/samples/hello/hello_c_tab/france.png +0 -0
- data/samples/hello/hello_c_tab/germany.png +0 -0
- data/samples/hello/hello_c_tab/italy.png +0 -0
- data/samples/hello/hello_c_tab/mexico.png +0 -0
- data/samples/hello/hello_c_tab/netherlands.png +0 -0
- data/samples/hello/hello_c_tab/norway.png +0 -0
- data/samples/hello/hello_c_tab/usa.png +0 -0
- data/samples/hello/hello_canvas.rb +5 -5
- data/samples/hello/hello_canvas_animation_data_binding.rb +1 -1
- data/samples/hello/hello_canvas_data_binding.rb +16 -16
- data/samples/hello/hello_checkbox.rb +4 -4
- data/samples/hello/hello_code_text.rb +3 -57
- data/samples/hello/hello_color_dialog.rb +1 -1
- data/samples/hello/hello_combo.rb +1 -1
- data/samples/hello/hello_computed.rb +5 -5
- data/samples/hello/hello_custom_widget.rb +1 -1
- data/samples/hello/hello_date_time.rb +4 -4
- data/samples/hello/hello_dialog.rb +3 -2
- data/samples/hello/hello_drag_and_drop.rb +1 -1
- data/samples/hello/hello_file_dialog.rb +1 -1
- data/samples/hello/hello_font_dialog.rb +3 -3
- data/samples/hello/hello_group.rb +6 -6
- data/samples/hello/hello_link.rb +56 -50
- data/samples/hello/hello_list_multi_selection.rb +1 -1
- data/samples/hello/hello_list_single_selection.rb +1 -1
- data/samples/hello/hello_progress_bar.rb +10 -10
- data/samples/hello/hello_radio.rb +6 -6
- data/samples/hello/hello_sash_form.rb +4 -4
- data/samples/hello/hello_shape.rb +1 -0
- data/samples/hello/hello_spinner.rb +6 -2
- data/samples/hello/hello_styled_text.rb +11 -11
- data/samples/hello/hello_tab.rb +2 -0
- data/vendor/swt/linux/swt.jar +0 -0
- data/vendor/swt/linux_aarch64/swt.jar +0 -0
- data/vendor/swt/mac/swt.jar +0 -0
- data/vendor/swt/mac_aarch64/swt.jar +0 -0
- data/vendor/swt/windows/swt.jar +0 -0
- metadata +76 -32
@@ -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
|
data/lib/glimmer/launcher.rb
CHANGED
@@ -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])
|
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,12 +67,16 @@ 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}?")}
|
75
73
|
end
|
74
|
+
|
75
|
+
def special_cpu_architecture_suffix
|
76
|
+
host_cpu = OS.host_cpu.downcase
|
77
|
+
special = host_cpu.include?('aarch64') || host_cpu.include?('arm')
|
78
|
+
special ? "_aarch64" : ''
|
79
|
+
end
|
76
80
|
|
77
81
|
def swt_jar_file
|
78
82
|
@swt_jar_file ||= File.expand_path(File.join(__FILE__, '..', '..', '..', 'vendor', 'swt', platform_os, 'swt.jar'))
|
@@ -83,14 +87,12 @@ module Glimmer
|
|
83
87
|
end
|
84
88
|
|
85
89
|
def glimmer_lib
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
puts "[DEVELOPMENT MODE] (detected #{@glimmer_lib})"
|
93
|
-
end
|
90
|
+
unless @glimmer_lib
|
91
|
+
@glimmer_lib = GLIMMER_LIB_GEM
|
92
|
+
glimmer_gem_listing = `jgem list #{GLIMMER_LIB_GEM}`.split("\n").map {|l| l.split.first}
|
93
|
+
if !glimmer_gem_listing.include?(GLIMMER_LIB_GEM) && File.exists?(GLIMMER_LIB_LOCAL)
|
94
|
+
@glimmer_lib = GLIMMER_LIB_LOCAL
|
95
|
+
puts "[DEVELOPMENT MODE] (detected #{@glimmer_lib})"
|
94
96
|
end
|
95
97
|
end
|
96
98
|
@glimmer_lib
|
@@ -115,17 +117,12 @@ module Glimmer
|
|
115
117
|
def launch(application, jruby_options: [], env_vars: {}, glimmer_options: {})
|
116
118
|
jruby_options_string = jruby_options.join(' ') + ' ' if jruby_options.any?
|
117
119
|
env_vars = env_vars.merge(glimmer_option_env_vars(glimmer_options))
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
else
|
122
|
-
"export #{k}=#{v} && "
|
123
|
-
end
|
124
|
-
end.join
|
120
|
+
env_vars.each do |k,v|
|
121
|
+
ENV[k] = v
|
122
|
+
end
|
125
123
|
the_glimmer_lib = glimmer_lib
|
126
|
-
devmode_require = nil
|
127
124
|
if the_glimmer_lib == GLIMMER_LIB_LOCAL
|
128
|
-
|
125
|
+
require 'puts_debuggerer'
|
129
126
|
end
|
130
127
|
require_relative 'rake_task'
|
131
128
|
rake_tasks = Rake.application.tasks.map(&:to_s).map {|t| t.sub('glimmer:', '')}
|
@@ -142,20 +139,9 @@ module Glimmer
|
|
142
139
|
puts "Running Glimmer rake task: #{rake_task}" if jruby_options_string.to_s.include?('--debug')
|
143
140
|
Rake::Task[rake_task].invoke(*rake_task_args)
|
144
141
|
else
|
145
|
-
|
146
|
-
|
147
|
-
|
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
|
142
|
+
puts "Launching Glimmer Application: #{application}" if jruby_options_string.to_s.include?('--debug') || glimmer_options['--quiet'].to_s.downcase != 'true'
|
143
|
+
require the_glimmer_lib
|
144
|
+
load File.expand_path(application)
|
159
145
|
end
|
160
146
|
end
|
161
147
|
end
|
@@ -168,14 +154,14 @@ module Glimmer
|
|
168
154
|
def initialize(raw_options)
|
169
155
|
raw_options << '--quiet' if !caller.join("\n").include?('/bin/glimmer:') && !raw_options.join.include?('--quiet=')
|
170
156
|
raw_options << '--log-level=DEBUG' if raw_options.join.include?('--debug') && !raw_options.join.include?('--log-level=')
|
171
|
-
@
|
157
|
+
@application_path = extract_application_path(raw_options)
|
172
158
|
@env_vars = extract_env_vars(raw_options)
|
173
159
|
@glimmer_options = extract_glimmer_options(raw_options)
|
174
160
|
@jruby_options = raw_options
|
175
161
|
end
|
176
162
|
|
177
163
|
def launch
|
178
|
-
if @
|
164
|
+
if @application_path.nil?
|
179
165
|
display_usage
|
180
166
|
else
|
181
167
|
launch_application
|
@@ -185,18 +171,13 @@ module Glimmer
|
|
185
171
|
private
|
186
172
|
|
187
173
|
def launch_application
|
188
|
-
load File.expand_path('./Rakefile') if File.exist?(File.expand_path('./Rakefile')) && caller.join("\n").include?('/bin/
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
glimmer_options: @glimmer_options
|
196
|
-
)
|
197
|
-
end
|
198
|
-
end
|
199
|
-
threads.each(&:join)
|
174
|
+
load File.expand_path('./Rakefile') if File.exist?(File.expand_path('./Rakefile')) && caller.join("\n").include?('/bin/glimmer_runner.rb:')
|
175
|
+
self.class.launch(
|
176
|
+
@application_path,
|
177
|
+
jruby_options: @jruby_options,
|
178
|
+
env_vars: @env_vars,
|
179
|
+
glimmer_options: @glimmer_options
|
180
|
+
)
|
200
181
|
end
|
201
182
|
|
202
183
|
def display_usage
|
@@ -232,10 +213,11 @@ module Glimmer
|
|
232
213
|
end
|
233
214
|
end
|
234
215
|
|
235
|
-
|
236
|
-
|
216
|
+
# Extract application path (which can also be a rake task, basically a non-arg)
|
217
|
+
def extract_application_path(options)
|
218
|
+
application_path = options.detect do |option|
|
237
219
|
!option.start_with?('-') && !option.include?('=')
|
238
|
-
end.
|
220
|
+
end.tap do
|
239
221
|
options.delete(application_path)
|
240
222
|
end
|
241
223
|
end
|
data/lib/glimmer/rake_task.rb
CHANGED
@@ -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.
|
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 = `
|
94
|
-
|
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
|
-
|
153
|
-
|
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}
|
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}
|
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}
|
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/#{
|
260
|
-
write "lib/#{
|
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/#{
|
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"
|
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 '
|
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 =
|
464
|
-
custom_widget_file_path += "
|
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)}.
|
471
|
+
#{class_name(app_name)}::View::AppView.launch
|
480
472
|
MULTI_LINE_STRING
|
481
473
|
end
|
482
474
|
|
483
|
-
def app_bin_command_file(
|
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 =
|
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 '
|
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
|
-
#
|
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.
|
550
|
-
lines.insert(gem_files_line_index+2, " gem.
|
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
|
-
|
599
|
-
|
600
|
-
|
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
|
-
|
607
|
-
|
608
|
-
|
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
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
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
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
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
|
-
|
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
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
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
|
-
|
672
|
-
|
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
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
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
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
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
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
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
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
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
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
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
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
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
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
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
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
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
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
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
|
|