glimmer-dsl-swt 0.6.9 → 4.17.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +276 -0
- data/LICENSE.txt +1 -1
- data/README.md +4017 -24
- data/VERSION +1 -1
- data/bin/girb +21 -0
- data/bin/girb_runner.rb +21 -0
- data/bin/glimmer +21 -0
- data/glimmer-dsl-swt.gemspec +187 -0
- data/lib/ext/glimmer.rb +21 -0
- data/lib/ext/glimmer/config.rb +21 -5
- data/lib/glimmer-dsl-swt.rb +27 -0
- data/lib/glimmer/Rakefile +21 -0
- data/lib/glimmer/data_binding/list_selection_binding.rb +21 -0
- data/lib/glimmer/data_binding/observable_widget.rb +21 -0
- data/lib/glimmer/data_binding/shine.rb +22 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +21 -0
- data/lib/glimmer/data_binding/tree_items_binding.rb +21 -0
- data/lib/glimmer/data_binding/widget_binding.rb +21 -0
- data/lib/glimmer/dsl/swt/async_exec_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/bind_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/block_property_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/color_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/column_properties_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/cursor_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +20 -0
- data/lib/glimmer/dsl/swt/data_binding_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/dialog_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/display_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/dnd_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/dsl.rb +21 -0
- data/lib/glimmer/dsl/swt/exec_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/font_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/image_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/layout_data_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/layout_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/menu_bar_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/menu_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/message_box_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/observe_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/property_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/rgb_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/rgba_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/shell_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/swt_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/sync_exec_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/tab_item_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/tree_properties_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/widget_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/widget_listener_expression.rb +21 -0
- data/lib/glimmer/launcher.rb +34 -9
- data/lib/glimmer/rake_task.rb +66 -85
- data/lib/glimmer/rake_task/list.rb +25 -1
- data/lib/glimmer/rake_task/package.rb +128 -0
- data/lib/glimmer/rake_task/sample.rb +115 -0
- data/lib/glimmer/rake_task/scaffold.rb +661 -0
- data/lib/glimmer/swt/color_proxy.rb +21 -0
- data/lib/glimmer/swt/cursor_proxy.rb +21 -0
- data/lib/glimmer/swt/display_proxy.rb +21 -0
- data/lib/glimmer/swt/dnd_proxy.rb +21 -0
- data/lib/glimmer/swt/font_proxy.rb +21 -0
- data/lib/glimmer/swt/image_proxy.rb +21 -0
- data/lib/glimmer/swt/layout_data_proxy.rb +21 -0
- data/lib/glimmer/swt/layout_proxy.rb +21 -0
- data/lib/glimmer/swt/menu_proxy.rb +21 -0
- data/lib/glimmer/swt/message_box_proxy.rb +21 -0
- data/lib/glimmer/swt/packages.rb +21 -0
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +21 -0
- data/lib/glimmer/swt/shell_proxy.rb +22 -0
- data/lib/glimmer/swt/style_constantizable.rb +21 -0
- data/lib/glimmer/swt/swt_proxy.rb +21 -0
- data/lib/glimmer/swt/tab_item_proxy.rb +21 -0
- data/lib/glimmer/swt/table_column_proxy.rb +21 -0
- data/lib/glimmer/swt/table_proxy.rb +21 -0
- data/lib/glimmer/swt/tree_proxy.rb +21 -0
- data/lib/glimmer/swt/widget_listener_proxy.rb +21 -0
- data/lib/glimmer/swt/widget_proxy.rb +24 -0
- data/lib/glimmer/ui/custom_shell.rb +21 -0
- data/lib/glimmer/ui/custom_widget.rb +29 -4
- data/lib/glimmer/util/proc_tracker.rb +23 -0
- data/samples/elaborate/contact_manager.rb +21 -0
- data/samples/elaborate/contact_manager/contact.rb +21 -0
- data/samples/elaborate/contact_manager/contact_manager_presenter.rb +21 -0
- data/samples/elaborate/contact_manager/contact_repository.rb +21 -0
- data/samples/elaborate/login.rb +20 -2
- data/samples/elaborate/tic_tac_toe.rb +21 -0
- data/samples/elaborate/tic_tac_toe/board.rb +21 -0
- data/samples/elaborate/tic_tac_toe/cell.rb +21 -0
- data/samples/elaborate/user_profile.rb +21 -0
- data/samples/hello/hello_browser.rb +22 -1
- data/samples/hello/hello_combo.rb +21 -0
- data/samples/hello/hello_computed.rb +21 -0
- data/samples/hello/hello_computed/contact.rb +21 -0
- data/samples/hello/hello_custom_shell.rb +134 -0
- data/samples/hello/hello_custom_widget.rb +65 -0
- data/samples/hello/hello_drag_and_drop.rb +21 -0
- data/samples/hello/hello_list_multi_selection.rb +21 -0
- data/samples/hello/hello_list_single_selection.rb +21 -0
- data/samples/hello/hello_menu_bar.rb +21 -0
- data/samples/hello/hello_message_box.rb +21 -0
- data/samples/hello/hello_pop_up_context_menu.rb +21 -0
- data/samples/hello/hello_tab.rb +21 -0
- data/samples/hello/hello_world.rb +21 -0
- data/vendor/swt/linux/swt.jar +0 -0
- data/vendor/swt/mac/swt.jar +0 -0
- data/vendor/swt/windows/swt.jar +0 -0
- metadata +52 -61
- data/lib/glimmer/package.rb +0 -91
- data/lib/glimmer/scaffold.rb +0 -631
data/lib/glimmer/scaffold.rb
DELETED
@@ -1,631 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'os'
|
3
|
-
require 'facets'
|
4
|
-
|
5
|
-
# TODO refactor to nest under RakeTask namespace
|
6
|
-
|
7
|
-
MAIN_OBJECT = self
|
8
|
-
|
9
|
-
class Scaffold
|
10
|
-
class << self
|
11
|
-
include FileUtils
|
12
|
-
|
13
|
-
VERSION = File.read(File.expand_path('../../../VERSION', __FILE__)).strip
|
14
|
-
RUBY_VERSION = File.read(File.expand_path('../../../RUBY_VERSION', __FILE__)).strip
|
15
|
-
|
16
|
-
# TODO externalize all constants into scaffold/files
|
17
|
-
|
18
|
-
GITIGNORE = <<~MULTI_LINE_STRING
|
19
|
-
*.gem
|
20
|
-
*.rbc
|
21
|
-
/.config
|
22
|
-
/coverage/
|
23
|
-
/InstalledFiles
|
24
|
-
/pkg/
|
25
|
-
/spec/reports/
|
26
|
-
/spec/examples.txt
|
27
|
-
/test/tmp/
|
28
|
-
/test/version_tmp/
|
29
|
-
/tmp/
|
30
|
-
|
31
|
-
# Used by dotenv library to load environment variables.
|
32
|
-
# .env
|
33
|
-
|
34
|
-
## Specific to RubyMotion:
|
35
|
-
.dat*
|
36
|
-
.repl_history
|
37
|
-
build/
|
38
|
-
*.bridgesupport
|
39
|
-
build-iPhoneOS/
|
40
|
-
build-iPhoneSimulator/
|
41
|
-
|
42
|
-
## Specific to RubyMotion (use of CocoaPods):
|
43
|
-
#
|
44
|
-
# We recommend against adding the Pods directory to your .gitignore. However
|
45
|
-
# you should judge for yourself, the pros and cons are mentioned at:
|
46
|
-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
47
|
-
#
|
48
|
-
# vendor/Pods/
|
49
|
-
|
50
|
-
## Documentation cache and generated files:
|
51
|
-
/.yardoc/
|
52
|
-
/_yardoc/
|
53
|
-
/doc/
|
54
|
-
/rdoc/
|
55
|
-
|
56
|
-
## Environment normalization:
|
57
|
-
/.bundle/
|
58
|
-
/vendor/bundle
|
59
|
-
/lib/bundler/man/
|
60
|
-
|
61
|
-
# for a library or gem, you might want to ignore these files since the code is
|
62
|
-
# intended to run in multiple environments; otherwise, check them in:
|
63
|
-
# Gemfile.lock
|
64
|
-
# .ruby-version
|
65
|
-
# .ruby-gemset
|
66
|
-
|
67
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
68
|
-
.rvmrc
|
69
|
-
|
70
|
-
# Mac
|
71
|
-
.DS_Store
|
72
|
-
|
73
|
-
# Gladiator (Glimmer Editor)
|
74
|
-
.gladiator
|
75
|
-
|
76
|
-
# Glimmer
|
77
|
-
dist
|
78
|
-
packages
|
79
|
-
vendor/jars
|
80
|
-
MULTI_LINE_STRING
|
81
|
-
|
82
|
-
GEMFILE = <<~MULTI_LINE_STRING
|
83
|
-
# frozen_string_literal: true
|
84
|
-
|
85
|
-
source 'https://rubygems.org'
|
86
|
-
|
87
|
-
git_source(:github) {|repo_name| "https://github.com/\#{repo_name}" }
|
88
|
-
|
89
|
-
gem 'glimmer-dsl-swt', '~> #{VERSION}'
|
90
|
-
|
91
|
-
group :development do
|
92
|
-
gem 'rspec', '~> 3.5.0'
|
93
|
-
gem 'git-glimmer', '1.7.0'
|
94
|
-
gem 'jeweler', '2.3.9'
|
95
|
-
gem 'simplecov', '>= 0'
|
96
|
-
end
|
97
|
-
MULTI_LINE_STRING
|
98
|
-
|
99
|
-
RVM_FUNCTION = <<~MULTI_LINE_STRING
|
100
|
-
# Load RVM into a shell session *as a function*
|
101
|
-
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
|
102
|
-
|
103
|
-
# First try to load from a user install
|
104
|
-
source "$HOME/.rvm/scripts/rvm"
|
105
|
-
|
106
|
-
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
|
107
|
-
|
108
|
-
# Then try to load from a root install
|
109
|
-
source "/usr/local/rvm/scripts/rvm"
|
110
|
-
|
111
|
-
fi
|
112
|
-
MULTI_LINE_STRING
|
113
|
-
|
114
|
-
def app(app_name)
|
115
|
-
gem_name = file_name(app_name)
|
116
|
-
gem_summary = human_name(app_name)
|
117
|
-
system "jruby -r git-glimmer -S jeweler --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
|
118
|
-
cd gem_name
|
119
|
-
rm_rf 'lib'
|
120
|
-
write '.gitignore', GITIGNORE
|
121
|
-
write '.ruby-version', RUBY_VERSION
|
122
|
-
write '.ruby-gemset', app_name
|
123
|
-
write 'VERSION', '1.0.0'
|
124
|
-
write 'LICENSE.txt', "Copyright (c) #{Time.now.year} #{app_name}"
|
125
|
-
write 'Gemfile', GEMFILE
|
126
|
-
write 'Rakefile', gem_rakefile(app_name, nil, gem_name)
|
127
|
-
mkdir 'app'
|
128
|
-
write "app/#{file_name(app_name)}.rb", app_main_file(app_name)
|
129
|
-
mkdir 'app/models'
|
130
|
-
mkdir 'app/views'
|
131
|
-
custom_shell('AppView', current_dir_name, :app)
|
132
|
-
|
133
|
-
mkdir_p 'package/windows'
|
134
|
-
icon_file = "package/windows/#{human_name(app_name)}.ico"
|
135
|
-
cp File.expand_path('../../../icons/scaffold_app.ico', __FILE__), icon_file
|
136
|
-
puts "Created #{current_dir_name}/#{icon_file}"
|
137
|
-
|
138
|
-
mkdir_p 'package/macosx'
|
139
|
-
icon_file = "package/macosx/#{human_name(app_name)}.icns"
|
140
|
-
cp File.expand_path('../../../icons/scaffold_app.icns', __FILE__), icon_file
|
141
|
-
puts "Created #{current_dir_name}/#{icon_file}"
|
142
|
-
|
143
|
-
mkdir_p 'package/linux'
|
144
|
-
icon_file = "package/linux/#{human_name(app_name)}.png"
|
145
|
-
cp File.expand_path('../../../icons/scaffold_app.png', __FILE__), icon_file
|
146
|
-
puts "Created #{current_dir_name}/#{icon_file}"
|
147
|
-
|
148
|
-
mkdir 'bin'
|
149
|
-
write "bin/#{file_name(app_name)}", app_bin_file(app_name)
|
150
|
-
write 'spec/spec_helper.rb', spec_helper_file
|
151
|
-
if OS.windows?
|
152
|
-
system "bundle"
|
153
|
-
system "glimmer package[image]"
|
154
|
-
system "\"packages/bundles/#{human_name(app_name)}/#{human_name(app_name)}.exe\""
|
155
|
-
else
|
156
|
-
system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n glimmer package\n'"
|
157
|
-
if OS.mac?
|
158
|
-
system "open packages/bundles/#{human_name(app_name).gsub(' ', '\ ')}.app"
|
159
|
-
else
|
160
|
-
system "glimmer bin/#{file_name(app_name)}"
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
def custom_shell(custom_shell_name, namespace, shell_type = nil)
|
166
|
-
namespace ||= current_dir_name
|
167
|
-
root_dir = File.exists?('app') ? 'app' : 'lib'
|
168
|
-
parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
|
169
|
-
mkdir_p parent_dir unless File.exists?(parent_dir)
|
170
|
-
write "#{parent_dir}/#{file_name(custom_shell_name)}.rb", custom_shell_file(custom_shell_name, namespace, shell_type)
|
171
|
-
end
|
172
|
-
|
173
|
-
def custom_widget(custom_widget_name, namespace)
|
174
|
-
namespace ||= current_dir_name
|
175
|
-
root_dir = File.exists?('app') ? 'app' : 'lib'
|
176
|
-
parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
|
177
|
-
mkdir_p parent_dir unless File.exists?(parent_dir)
|
178
|
-
write "#{parent_dir}/#{file_name(custom_widget_name)}.rb", custom_widget_file(custom_widget_name, namespace)
|
179
|
-
end
|
180
|
-
|
181
|
-
def custom_shell_gem(custom_shell_name, namespace)
|
182
|
-
gem_name = "glimmer-cs-#{compact_name(custom_shell_name)}"
|
183
|
-
gem_summary = "#{human_name(custom_shell_name)} - Glimmer Custom Shell"
|
184
|
-
begin
|
185
|
-
custom_shell_keyword = dsl_widget_name(custom_shell_name)
|
186
|
-
MAIN_OBJECT.method(custom_shell_keyword)
|
187
|
-
return puts("CustomShell keyword `#{custom_shell_keyword}` is unavailable (occupied by a built-in Ruby method)! Please pick a different name.")
|
188
|
-
rescue NameError
|
189
|
-
# No Op (keyword is not taken by a built in Ruby method)
|
190
|
-
end
|
191
|
-
if namespace
|
192
|
-
gem_name += "-#{compact_name(namespace)}"
|
193
|
-
gem_summary += " (#{human_name(namespace)})"
|
194
|
-
else
|
195
|
-
return puts('Namespace is required! Usage: glimmer scaffold:gem:customshell[name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
|
196
|
-
namespace = 'glimmer'
|
197
|
-
end
|
198
|
-
system "jruby -r git-glimmer -S jeweler --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
|
199
|
-
cd gem_name
|
200
|
-
write '.gitignore', GITIGNORE
|
201
|
-
write '.ruby-version', RUBY_VERSION
|
202
|
-
write '.ruby-gemset', gem_name
|
203
|
-
write 'VERSION', '1.0.0'
|
204
|
-
write 'Gemfile', GEMFILE
|
205
|
-
write 'Rakefile', gem_rakefile(custom_shell_name, namespace, gem_name)
|
206
|
-
append "lib/#{gem_name}.rb", gem_main_file(custom_shell_name, namespace)
|
207
|
-
mkdir 'lib/views'
|
208
|
-
custom_shell(custom_shell_name, namespace, :gem)
|
209
|
-
mkdir 'bin'
|
210
|
-
write "bin/#{gem_name}", gem_bin_file(gem_name, custom_shell_name, namespace)
|
211
|
-
write "bin/#{file_name(custom_shell_name)}", gem_bin_command_file(gem_name)
|
212
|
-
FileUtils.chmod 0755, "bin/#{file_name(custom_shell_name)}"
|
213
|
-
write 'spec/spec_helper.rb', spec_helper_file
|
214
|
-
|
215
|
-
mkdir_p 'package/windows'
|
216
|
-
icon_file = "package/windows/#{human_name(custom_shell_name)}.ico"
|
217
|
-
cp File.expand_path('../../../icons/scaffold_app.ico', __FILE__), icon_file
|
218
|
-
puts "Created #{current_dir_name}/#{icon_file}"
|
219
|
-
|
220
|
-
mkdir_p 'package/macosx'
|
221
|
-
icon_file = "package/macosx/#{human_name(custom_shell_name)}.icns"
|
222
|
-
cp File.expand_path('../../../icons/scaffold_app.icns', __FILE__), icon_file
|
223
|
-
puts "Created #{current_dir_name}/#{icon_file}"
|
224
|
-
|
225
|
-
mkdir_p 'package/linux'
|
226
|
-
icon_file = "package/linux/#{human_name(custom_shell_name)}.png"
|
227
|
-
cp File.expand_path('../../../icons/scaffold_app.png', __FILE__), icon_file
|
228
|
-
puts "Created #{current_dir_name}/#{icon_file}"
|
229
|
-
|
230
|
-
if OS.windows?
|
231
|
-
system "bundle"
|
232
|
-
system "glimmer package[image]"
|
233
|
-
system "\"packages/bundles/#{human_name(custom_shell_name)}/#{human_name(custom_shell_name)}.exe\""
|
234
|
-
else
|
235
|
-
system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n glimmer package\n'"
|
236
|
-
if OS.mac?
|
237
|
-
system "open packages/bundles/#{human_name(custom_shell_name).gsub(' ', '\ ')}.app" if OS.mac?
|
238
|
-
else
|
239
|
-
system "bin/#{file_name(custom_shell_name)}"
|
240
|
-
end
|
241
|
-
end
|
242
|
-
puts "Finished creating #{gem_name} Ruby gem."
|
243
|
-
puts 'Edit Rakefile to configure gem details.'
|
244
|
-
puts 'Run `rake` to execute specs.'
|
245
|
-
puts 'Run `rake build` to build gem.'
|
246
|
-
puts 'Run `rake release` to release into rubygems.org once ready.'
|
247
|
-
end
|
248
|
-
|
249
|
-
def custom_widget_gem(custom_widget_name, namespace)
|
250
|
-
return puts('Namespace is required! Usage: glimmer scaffold:custom_widget_gem[custom_widget_name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
|
251
|
-
gem_name = "glimmer-cw-#{compact_name(custom_widget_name)}"
|
252
|
-
gem_summary = "#{human_name(custom_widget_name)} - Glimmer Custom Widget"
|
253
|
-
if namespace
|
254
|
-
gem_name += "-#{compact_name(namespace)}"
|
255
|
-
gem_summary += " (#{human_name(namespace)})"
|
256
|
-
else
|
257
|
-
namespace = 'glimmer'
|
258
|
-
end
|
259
|
-
system "jruby -r git-glimmer -S jeweler --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
|
260
|
-
cd gem_name
|
261
|
-
write '.gitignore', GITIGNORE
|
262
|
-
write '.ruby-version', RUBY_VERSION
|
263
|
-
write '.ruby-gemset', gem_name
|
264
|
-
write 'VERSION', '1.0.0'
|
265
|
-
write 'Gemfile', GEMFILE
|
266
|
-
write 'Rakefile', gem_rakefile
|
267
|
-
write 'spec/spec_helper.rb', spec_helper_file
|
268
|
-
append "lib/#{gem_name}.rb", gem_main_file(custom_widget_name, namespace)
|
269
|
-
mkdir 'lib/views'
|
270
|
-
custom_widget(custom_widget_name, namespace)
|
271
|
-
if OS.windows?
|
272
|
-
system "bundle"
|
273
|
-
else
|
274
|
-
system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n'"
|
275
|
-
end
|
276
|
-
puts "Finished creating #{gem_name} Ruby gem."
|
277
|
-
puts 'Edit Rakefile to configure gem details.'
|
278
|
-
puts 'Run `rake` to execute specs.'
|
279
|
-
puts 'Run `rake build` to build gem.'
|
280
|
-
puts 'Run `rake release` to release into rubygems.org once ready.'
|
281
|
-
end
|
282
|
-
|
283
|
-
private
|
284
|
-
|
285
|
-
def write(file, content)
|
286
|
-
File.write file, content
|
287
|
-
file_path = File.expand_path(file)
|
288
|
-
puts "Created #{current_dir_name}/#{file}"
|
289
|
-
end
|
290
|
-
|
291
|
-
def append(file, content)
|
292
|
-
File.open(file, 'a') do |f|
|
293
|
-
f.write(content)
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
def current_dir_name
|
298
|
-
File.basename(File.expand_path('.'))
|
299
|
-
end
|
300
|
-
|
301
|
-
def class_name(app_name)
|
302
|
-
app_name.underscore.camelcase(:upper)
|
303
|
-
end
|
304
|
-
|
305
|
-
def file_name(app_name)
|
306
|
-
app_name.underscore
|
307
|
-
end
|
308
|
-
alias dsl_widget_name file_name
|
309
|
-
|
310
|
-
def human_name(app_name)
|
311
|
-
app_name.underscore.titlecase
|
312
|
-
end
|
313
|
-
|
314
|
-
def compact_name(gem_name)
|
315
|
-
gem_name.underscore.camelcase.downcase
|
316
|
-
end
|
317
|
-
|
318
|
-
def app_main_file(app_name)
|
319
|
-
<<~MULTI_LINE_STRING
|
320
|
-
$LOAD_PATH.unshift(File.expand_path('..', __FILE__))
|
321
|
-
|
322
|
-
require 'bundler/setup'
|
323
|
-
Bundler.require(:default)
|
324
|
-
require 'views/#{file_name(app_name)}/app_view'
|
325
|
-
|
326
|
-
class #{class_name(app_name)}
|
327
|
-
include Glimmer
|
328
|
-
|
329
|
-
APP_ROOT = File.expand_path('../..', __FILE__)
|
330
|
-
VERSION = File.read(File.join(APP_ROOT, 'VERSION'))
|
331
|
-
LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
|
332
|
-
|
333
|
-
def open
|
334
|
-
app_view.open
|
335
|
-
end
|
336
|
-
end
|
337
|
-
MULTI_LINE_STRING
|
338
|
-
end
|
339
|
-
|
340
|
-
def gem_main_file(custom_widget_name, namespace = nil)
|
341
|
-
custom_widget_file_path = "views"
|
342
|
-
custom_widget_file_path += "/#{file_name(namespace)}" if namespace
|
343
|
-
custom_widget_file_path += "/#{file_name(custom_widget_name)}"
|
344
|
-
|
345
|
-
<<~MULTI_LINE_STRING
|
346
|
-
$LOAD_PATH.unshift(File.expand_path('..', __FILE__))
|
347
|
-
|
348
|
-
require 'glimmer-dsl-swt'
|
349
|
-
require '#{custom_widget_file_path}'
|
350
|
-
MULTI_LINE_STRING
|
351
|
-
end
|
352
|
-
|
353
|
-
def app_bin_file(app_name)
|
354
|
-
<<~MULTI_LINE_STRING
|
355
|
-
require_relative '../app/#{file_name(app_name)}'
|
356
|
-
|
357
|
-
#{class_name(app_name)}.new.open
|
358
|
-
MULTI_LINE_STRING
|
359
|
-
end
|
360
|
-
|
361
|
-
def gem_bin_file(gem_name, custom_shell_name, namespace)
|
362
|
-
# TODO change this so that it does not mix Glimmer unto the main object
|
363
|
-
<<~MULTI_LINE_STRING
|
364
|
-
require_relative '../lib/#{gem_name}'
|
365
|
-
|
366
|
-
class #{class_name(custom_shell_name)}App
|
367
|
-
include Glimmer
|
368
|
-
|
369
|
-
def open
|
370
|
-
#{dsl_widget_name(custom_shell_name)}.open
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
|
-
#{class_name(custom_shell_name)}App.new.open
|
375
|
-
MULTI_LINE_STRING
|
376
|
-
end
|
377
|
-
|
378
|
-
def gem_bin_command_file(gem_name)
|
379
|
-
<<~MULTI_LINE_STRING
|
380
|
-
#!/usr/bin/env jruby
|
381
|
-
|
382
|
-
require 'glimmer/launcher'
|
383
|
-
|
384
|
-
runner = File.expand_path("../#{gem_name}", __FILE__)
|
385
|
-
launcher = Glimmer::Launcher.new([runner] + ARGV)
|
386
|
-
launcher.launch
|
387
|
-
MULTI_LINE_STRING
|
388
|
-
end
|
389
|
-
|
390
|
-
def gem_rakefile(custom_shell_name = nil, namespace = nil, gem_name = nil)
|
391
|
-
rakefile_content = File.read('Rakefile')
|
392
|
-
lines = rakefile_content.split("\n")
|
393
|
-
require_rake_line_index = lines.index(lines.detect {|l| l.include?("require 'rake'") })
|
394
|
-
lines.insert(require_rake_line_index, "require 'glimmer/launcher'")
|
395
|
-
gem_files_line_index = lines.index(lines.detect {|l| l.include?('# dependencies defined in Gemfile') })
|
396
|
-
if custom_shell_name
|
397
|
-
lines.insert(gem_files_line_index, " gem.files = Dir['VERSION', 'LICENSE.txt', 'lib/**/*', 'app/**/*', 'bin/**/*', 'vendor/**/*', 'package/**/*']")
|
398
|
-
lines.insert(gem_files_line_index+1, " gem.executables = ['#{gem_name}', '#{file_name(custom_shell_name)}']")
|
399
|
-
lines.insert(gem_files_line_index+2, " gem.require_paths = ['vendor', 'lib', 'app']")
|
400
|
-
else
|
401
|
-
lines.insert(gem_files_line_index, " gem.files = Dir['VERSION', 'LICENSE.txt', 'lib/**/*']")
|
402
|
-
end
|
403
|
-
spec_pattern_line_index = lines.index(lines.detect {|l| l.include?('spec.pattern =') })
|
404
|
-
lines.insert(spec_pattern_line_index+1, " spec.ruby_opts = [Glimmer::Launcher.jruby_swt_options]")
|
405
|
-
lines << "\nrequire 'glimmer/rake_task'\n"
|
406
|
-
file_content = lines.join("\n")
|
407
|
-
if custom_shell_name
|
408
|
-
file_content << <<~MULTI_LINE_STRING
|
409
|
-
Glimmer::Package.javapackager_extra_args =
|
410
|
-
" -name '#{human_name(custom_shell_name)}'" +
|
411
|
-
" -title '#{human_name(custom_shell_name)}'" +
|
412
|
-
" -Bmac.CFBundleName='#{human_name(custom_shell_name)}'" +
|
413
|
-
" -Bmac.CFBundleIdentifier='org.#{namespace ? compact_name(namespace) : compact_name(custom_shell_name)}.application.#{compact_name(custom_shell_name).capitalize}'"
|
414
|
-
# " -BlicenseType=" +
|
415
|
-
# " -Bmac.category=" +
|
416
|
-
# " -Bmac.signing-key-developer-id-app="
|
417
|
-
MULTI_LINE_STRING
|
418
|
-
end
|
419
|
-
file_content
|
420
|
-
end
|
421
|
-
|
422
|
-
def spec_helper_file
|
423
|
-
content = File.read('spec/spec_helper.rb')
|
424
|
-
lines = content.split("\n")
|
425
|
-
require_line_index = lines.index(lines.detect {|l| l.include?(current_dir_name) })
|
426
|
-
lines[require_line_index..require_line_index] = [
|
427
|
-
"require 'bundler/setup'",
|
428
|
-
'Bundler.require(:default, :development)',
|
429
|
-
]
|
430
|
-
configure_block_line_index = lines.index(lines.detect {|l| l.include?('RSpec.configure do') }) + 1
|
431
|
-
lines[configure_block_line_index...configure_block_line_index] = [
|
432
|
-
' # The following ensures rspec tests that instantiate and set Glimmer DSL widgets in @target get cleaned after',
|
433
|
-
' config.after do',
|
434
|
-
' @target.dispose if @target && @target.respond_to?(:dispose)',
|
435
|
-
' Glimmer::DSL::Engine.reset',
|
436
|
-
' end',
|
437
|
-
]
|
438
|
-
|
439
|
-
lines << "\nrequire 'glimmer/rake_task'\n"
|
440
|
-
lines.join("\n")
|
441
|
-
end
|
442
|
-
|
443
|
-
def custom_shell_file(custom_shell_name, namespace, shell_type)
|
444
|
-
namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
|
445
|
-
|
446
|
-
custom_shell_file_content = <<-MULTI_LINE_STRING
|
447
|
-
#{namespace_type} #{class_name(namespace)}
|
448
|
-
class #{class_name(custom_shell_name)}
|
449
|
-
include Glimmer::UI::CustomShell
|
450
|
-
|
451
|
-
MULTI_LINE_STRING
|
452
|
-
|
453
|
-
if shell_type == :gem
|
454
|
-
custom_shell_file_content += <<-MULTI_LINE_STRING
|
455
|
-
APP_ROOT = File.expand_path('../../../..', __FILE__)
|
456
|
-
VERSION = File.read(File.join(APP_ROOT, 'VERSION'))
|
457
|
-
LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
|
458
|
-
|
459
|
-
MULTI_LINE_STRING
|
460
|
-
end
|
461
|
-
|
462
|
-
custom_shell_file_content += <<-MULTI_LINE_STRING
|
463
|
-
## Add options like the following to configure CustomShell by outside consumers
|
464
|
-
#
|
465
|
-
# options :title, :background_color
|
466
|
-
# option :width, default: 320
|
467
|
-
# option :height, default: 240
|
468
|
-
option :greeting, default: 'Hello, World!'
|
469
|
-
|
470
|
-
## Use before_body block to pre-initialize variables to use in body
|
471
|
-
#
|
472
|
-
#
|
473
|
-
MULTI_LINE_STRING
|
474
|
-
|
475
|
-
if %i[gem app].include?(shell_type)
|
476
|
-
custom_shell_file_content += <<-MULTI_LINE_STRING
|
477
|
-
before_body {
|
478
|
-
Display.setAppName('#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}')
|
479
|
-
Display.setAppVersion(VERSION)
|
480
|
-
@display = display {
|
481
|
-
on_about {
|
482
|
-
display_about_dialog
|
483
|
-
}
|
484
|
-
on_preferences {
|
485
|
-
display_preferences_dialog
|
486
|
-
}
|
487
|
-
}
|
488
|
-
}
|
489
|
-
MULTI_LINE_STRING
|
490
|
-
else
|
491
|
-
custom_shell_file_content += <<-MULTI_LINE_STRING
|
492
|
-
# before_body {
|
493
|
-
#
|
494
|
-
# }
|
495
|
-
MULTI_LINE_STRING
|
496
|
-
end
|
497
|
-
|
498
|
-
custom_shell_file_content += <<-MULTI_LINE_STRING
|
499
|
-
|
500
|
-
## Use after_body block to setup observers for widgets in body
|
501
|
-
#
|
502
|
-
# after_body {
|
503
|
-
#
|
504
|
-
# }
|
505
|
-
|
506
|
-
## Add widget content inside custom shell body
|
507
|
-
## Top-most widget must be a shell or another custom shell
|
508
|
-
#
|
509
|
-
body {
|
510
|
-
shell {
|
511
|
-
# Replace example content below with custom shell content
|
512
|
-
minimum_size 320, 240
|
513
|
-
image File.join(APP_ROOT, 'package', 'windows', "#{human_name(shell_type == :gem ? custom_shell_name : current_dir_name)}.ico") if OS.windows?
|
514
|
-
text "#{human_name(namespace)} - #{human_name(custom_shell_name)}"
|
515
|
-
grid_layout
|
516
|
-
label(:center) {
|
517
|
-
text bind(self, :greeting)
|
518
|
-
font height: 40
|
519
|
-
layout_data :fill, :center, true, true
|
520
|
-
}
|
521
|
-
menu_bar {
|
522
|
-
menu {
|
523
|
-
text '&File'
|
524
|
-
menu_item {
|
525
|
-
text '&Preferences...'
|
526
|
-
on_widget_selected {
|
527
|
-
display_preferences_dialog
|
528
|
-
}
|
529
|
-
}
|
530
|
-
}
|
531
|
-
}
|
532
|
-
}
|
533
|
-
}
|
534
|
-
MULTI_LINE_STRING
|
535
|
-
|
536
|
-
if %i[gem app].include?(shell_type)
|
537
|
-
custom_shell_file_content += <<-MULTI_LINE_STRING
|
538
|
-
|
539
|
-
def display_about_dialog
|
540
|
-
message_box(body_root) {
|
541
|
-
text 'About'
|
542
|
-
message "#{human_name(namespace)} - #{human_name(custom_shell_name)} \#{VERSION}\\n\\n\#{LICENSE}"
|
543
|
-
}.open
|
544
|
-
end
|
545
|
-
|
546
|
-
def display_preferences_dialog
|
547
|
-
dialog(swt_widget) {
|
548
|
-
text 'Preferences'
|
549
|
-
grid_layout {
|
550
|
-
margin_height 5
|
551
|
-
margin_width 5
|
552
|
-
}
|
553
|
-
group {
|
554
|
-
row_layout {
|
555
|
-
type :vertical
|
556
|
-
spacing 10
|
557
|
-
}
|
558
|
-
text 'Greeting'
|
559
|
-
font style: :bold
|
560
|
-
[
|
561
|
-
'Hello, World!',
|
562
|
-
'Howdy, Partner!'
|
563
|
-
].each do |greeting_text|
|
564
|
-
button(:radio) {
|
565
|
-
text greeting_text
|
566
|
-
selection bind(self, :greeting) { |g| g == greeting_text }
|
567
|
-
layout_data {
|
568
|
-
width 160
|
569
|
-
}
|
570
|
-
on_widget_selected { |event|
|
571
|
-
self.greeting = event.widget.getText
|
572
|
-
}
|
573
|
-
}
|
574
|
-
end
|
575
|
-
}
|
576
|
-
}.open
|
577
|
-
end
|
578
|
-
MULTI_LINE_STRING
|
579
|
-
end
|
580
|
-
|
581
|
-
custom_shell_file_content += <<-MULTI_LINE_STRING
|
582
|
-
end
|
583
|
-
end
|
584
|
-
MULTI_LINE_STRING
|
585
|
-
end
|
586
|
-
|
587
|
-
def custom_widget_file(custom_widget_name, namespace)
|
588
|
-
namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
|
589
|
-
|
590
|
-
<<~MULTI_LINE_STRING
|
591
|
-
#{namespace_type} #{class_name(namespace)}
|
592
|
-
class #{class_name(custom_widget_name)}
|
593
|
-
include Glimmer::UI::CustomWidget
|
594
|
-
|
595
|
-
## Add options like the following to configure CustomWidget by outside consumers
|
596
|
-
#
|
597
|
-
# options :custom_text, :background_color
|
598
|
-
# option :foreground_color, default: :red
|
599
|
-
|
600
|
-
## Use before_body block to pre-initialize variables to use in body
|
601
|
-
#
|
602
|
-
#
|
603
|
-
# before_body {
|
604
|
-
#
|
605
|
-
# }
|
606
|
-
|
607
|
-
## Use after_body block to setup observers for widgets in body
|
608
|
-
#
|
609
|
-
# after_body {
|
610
|
-
#
|
611
|
-
# }
|
612
|
-
|
613
|
-
## Add widget content under custom widget body
|
614
|
-
##
|
615
|
-
## If you want to add a shell as the top-most widget,
|
616
|
-
## consider creating a custom shell instead
|
617
|
-
## (Glimmer::UI::CustomShell offers shell convenience methods, like show and hide)
|
618
|
-
#
|
619
|
-
body {
|
620
|
-
# Replace example content below with custom widget content
|
621
|
-
label {
|
622
|
-
background :red
|
623
|
-
}
|
624
|
-
}
|
625
|
-
|
626
|
-
end
|
627
|
-
end
|
628
|
-
MULTI_LINE_STRING
|
629
|
-
end
|
630
|
-
end
|
631
|
-
end
|