glimmer 0.8.2 → 0.9.0

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