glimmer-dsl-swt 0.6.3 → 0.6.8
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/README.md +3 -2
- data/VERSION +1 -1
- data/lib/ext/glimmer/config.rb +22 -2
- data/lib/glimmer-dsl-swt.rb +5 -9
- data/lib/glimmer/Rakefile +5 -0
- data/lib/glimmer/data_binding/table_items_binding.rb +4 -1
- data/lib/glimmer/launcher.rb +59 -21
- data/lib/glimmer/rake_task.rb +88 -1
- data/lib/glimmer/scaffold.rb +19 -3
- data/lib/glimmer/swt/shell_proxy.rb +0 -1
- data/lib/glimmer/swt/style_constantizable.rb +1 -0
- data/lib/glimmer/swt/table_proxy.rb +10 -0
- data/lib/glimmer/swt/widget_proxy.rb +20 -13
- data/samples/elaborate/contact_manager.rb +121 -0
- data/samples/elaborate/contact_manager/contact.rb +11 -0
- data/samples/elaborate/contact_manager/contact_manager_presenter.rb +26 -0
- data/samples/elaborate/contact_manager/contact_repository.rb +244 -0
- data/samples/elaborate/login.rb +108 -0
- data/samples/elaborate/tic_tac_toe.rb +55 -0
- data/samples/elaborate/tic_tac_toe/board.rb +124 -0
- data/samples/elaborate/tic_tac_toe/cell.rb +27 -0
- data/samples/elaborate/user_profile.rb +55 -0
- data/samples/hello/hello_browser.rb +8 -0
- data/samples/hello/hello_combo.rb +38 -0
- data/samples/hello/hello_computed.rb +69 -0
- data/samples/hello/hello_computed/contact.rb +21 -0
- data/samples/hello/hello_drag_and_drop.rb +29 -0
- data/samples/hello/hello_list_multi_selection.rb +48 -0
- data/samples/hello/hello_list_single_selection.rb +37 -0
- data/samples/hello/hello_menu_bar.rb +64 -0
- data/samples/hello/hello_message_box.rb +15 -0
- data/samples/hello/hello_pop_up_context_menu.rb +36 -0
- data/samples/hello/hello_tab.rb +24 -0
- data/samples/hello/hello_world.rb +8 -0
- metadata +64 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f75e570d4a595c012b464d8dffa7149200385d8053dc39640d5be59d8f4980c
|
4
|
+
data.tar.gz: 1fbd61272f851ffa8aa1f6dbcf0afa57e898147c3982f69a180018a2d5d0e6c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c78fc793f87813acaf59b2732a362fc37da683c79b2610dc7d9d74c37ddd56ee1ac5d33209ee509d2cc1a3c62a0fb5db56b8275d88a93b6c4d7e8c5906511b0
|
7
|
+
data.tar.gz: 90941e2906ecc6c87e6685f8c8ff62fda790a43c3af519761011cefa56466336e5705e8deb49e25eeef60020a7cf6ab65c19c7c3f1c1a0f325158053bcf778c4
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 0.6.
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 0.6.8 (JRuby Desktop GUI)
|
2
2
|
[](http://badge.fury.io/rb/glimmer-dsl-swt)
|
3
3
|
[](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
|
4
4
|
[](https://coveralls.io/github/AndyObtiva/glimmer-dsl-swt?branch=master)
|
5
5
|
[](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-swt/maintainability)
|
6
6
|
[](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
7
7
|
|
8
|
-
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [SWT](https://www.eclipse.org/swt/) enables desktop development with [Glimmer](https://github.com/AndyObtiva/glimmer).
|
8
|
+
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [SWT](https://www.eclipse.org/swt/) enables desktop development with [Glimmer](https://github.com/AndyObtiva/glimmer) in [JRuby](https://www.jruby.org/).
|
9
9
|
|
10
10
|
[Glimmer](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in Ruby. Glimmer's main innovation is a JRuby DSL that enables productive and efficient authoring of desktop application user-interfaces while relying on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in data-binding support to greatly facilitate synchronizing the GUI with domain models. As a result, that achieves true decoupling of object oriented components, enabling developers to solve business problems without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models test-first afterwards.
|
11
11
|
|
@@ -15,6 +15,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
15
15
|
- [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
|
16
16
|
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
|
17
17
|
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
|
18
|
+
- [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop GUI)
|
18
19
|
|
19
20
|
## Example
|
20
21
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.8
|
data/lib/ext/glimmer/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'glimmer/config'
|
2
|
+
|
1
3
|
module Glimmer
|
2
4
|
module Config
|
3
5
|
DEFAULT_IMPORT_SWT_PACKAGES = [
|
@@ -9,6 +11,11 @@ module Glimmer
|
|
9
11
|
'org.eclipse.swt.custom',
|
10
12
|
'org.eclipse.swt.dnd',
|
11
13
|
]
|
14
|
+
|
15
|
+
# This may be configured with extra sample directories from custom widget/shell gems
|
16
|
+
# following the convention of a `samples/subdirectory` where subdirectory is the
|
17
|
+
# custom widget/shell name or something representative of a group of samples (e.g. c_date_time).
|
18
|
+
SAMPLE_DIRECTORIES = []
|
12
19
|
|
13
20
|
class << self
|
14
21
|
# Tells Glimmer to import SWT packages into including class (default: true)
|
@@ -48,6 +55,10 @@ module Glimmer
|
|
48
55
|
|
49
56
|
def logging_appender_options
|
50
57
|
@@logging_appender_options = {async: true, auto_flushing: 500, write_size: 500, flush_period: 60, immediate_at: [:error, :fatal], layout: logging_layout} unless defined? @@logging_appender_options
|
58
|
+
# TODO make this a glimmer command option
|
59
|
+
if ENV['GLIMMER_LOGGER_ASYNC'].to_s.downcase == 'false'
|
60
|
+
@@logging_appender_options.merge!(async: false, auto_flushing: 1, immediate_at: [:debug, :info, :warn, :error, :fatal])
|
61
|
+
end
|
51
62
|
@@logging_appender_options
|
52
63
|
end
|
53
64
|
|
@@ -90,18 +101,27 @@ module Glimmer
|
|
90
101
|
end
|
91
102
|
logger.appenders = appenders
|
92
103
|
end
|
104
|
+
|
93
105
|
end
|
106
|
+
|
94
107
|
end
|
108
|
+
|
95
109
|
end
|
110
|
+
|
96
111
|
end
|
97
112
|
|
98
|
-
Glimmer::Config.reset_logger!
|
113
|
+
Glimmer::Config.reset_logger! unless ENV['GLIMMER_LOGGER_ENABLED'].to_s.downcase == 'false'
|
99
114
|
if ENV['GLIMMER_LOGGER_LEVEL']
|
100
115
|
# if glimmer log level is being overridden for debugging purposes, then disable async logging making logging immediate
|
101
116
|
Glimmer::Config.logging_appender_options = Glimmer::Config.logging_appender_options.merge(async: false, auto_flushing: 1)
|
102
117
|
Glimmer::Config.logging_devices = [:stdout]
|
103
|
-
|
118
|
+
begin
|
119
|
+
Glimmer::Config.logger.level = ENV['GLIMMER_LOGGER_LEVEL'].strip
|
120
|
+
rescue => e
|
121
|
+
puts e.message
|
122
|
+
end
|
104
123
|
end
|
124
|
+
|
105
125
|
Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
|
106
126
|
method = method_symbol.to_s
|
107
127
|
result = false
|
data/lib/glimmer-dsl-swt.rb
CHANGED
@@ -2,15 +2,11 @@ $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
|
|
2
2
|
|
3
3
|
# External requires
|
4
4
|
require 'java'
|
5
|
-
if ENV['
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
require 'logging'
|
11
|
-
require 'nested_inherited_jruby_include_package'
|
12
|
-
require 'super_module'
|
13
|
-
end
|
5
|
+
require 'puts_debuggerer' if ("#{ENV['pd']}#{ENV['PD']}").to_s.downcase.include?('true')
|
6
|
+
require 'glimmer'
|
7
|
+
require 'logging'
|
8
|
+
require 'nested_inherited_jruby_include_package'
|
9
|
+
require 'super_module'
|
14
10
|
|
15
11
|
# Internal requires
|
16
12
|
require 'ext/glimmer/config'
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# This Rakefile gets used from Glimmer::Launcher when the current directory for running the `glimmer` command
|
2
|
+
# does not have a Rakefile (e.g. during scaffolding).
|
3
|
+
# It is not needed when running from inside a scaffolded app or gem, or an app with a Rakefile that has
|
4
|
+
# `require 'glimmer/rake_task'`
|
5
|
+
require 'glimmer/rake_task'
|
@@ -30,7 +30,10 @@ module Glimmer
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def call(new_model_collection=nil)
|
33
|
-
new_model_collection = @model_binding.evaluate_property # this ensures applying converters (e.g. :on_read)
|
33
|
+
new_model_collection = @model_binding.evaluate_property # this ensures applying converters (e.g. :on_read)
|
34
|
+
table_cells = @table.swt_widget.items.map {|item| @table.column_properties.size.times.map {|i| item.get_text(i)} }
|
35
|
+
model_cells = new_model_collection.to_a.map {|m| @table.cells_for(m)}
|
36
|
+
return if table_cells == model_cells
|
34
37
|
if new_model_collection and new_model_collection.is_a?(Array)
|
35
38
|
@table_items_observer_registration&.unobserve
|
36
39
|
@table_items_observer_registration = observe(new_model_collection, @column_properties)
|
data/lib/glimmer/launcher.rb
CHANGED
@@ -1,36 +1,30 @@
|
|
1
|
-
|
1
|
+
require 'fileutils'
|
2
|
+
require 'os'
|
2
3
|
|
3
4
|
module Glimmer
|
4
5
|
class Launcher
|
5
6
|
OPERATING_SYSTEMS_SUPPORTED = ["mac", "windows", "linux"]
|
6
7
|
|
7
|
-
|
8
|
+
TEXT_USAGE = <<~MULTI_LINE_STRING
|
9
|
+
Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v#{File.read(File.expand_path('../../../VERSION', __FILE__))}
|
8
10
|
Usage: glimmer [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
9
11
|
|
10
|
-
Runs Glimmer applications
|
11
|
-
|
12
|
-
Either a single task or one or more applications may be specified.
|
13
|
-
|
14
|
-
When a task is specified, it runs via rake. Some tasks take arguments in square brackets.
|
15
|
-
|
16
|
-
Available tasks are below (if you do not see any, please add `require 'glimmer/rake_task'` to Rakefile and rerun or run rake -T):
|
17
|
-
MULTI_LINE_STRING
|
18
|
-
|
19
|
-
TEXT_USAGE_SUFFIX = <<~MULTI_LINE_STRING
|
12
|
+
Runs Glimmer applications and tasks.
|
20
13
|
|
21
14
|
When applications are specified, they are run using JRuby,
|
22
15
|
automatically preloading the glimmer Ruby gem and SWT jar dependency.
|
23
16
|
|
24
|
-
Optionally, extra Glimmer options, JRuby options and environment variables may be passed in.
|
17
|
+
Optionally, extra Glimmer options, JRuby options, and/or environment variables may be passed in.
|
25
18
|
|
26
19
|
Glimmer options:
|
27
20
|
- "--quiet" : Does not announce file path of Glimmer application being launched
|
28
21
|
- "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
|
29
22
|
- "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
|
30
23
|
|
31
|
-
|
24
|
+
Tasks are run via rake. Some tasks take arguments in square brackets.
|
32
25
|
|
33
|
-
|
26
|
+
Available tasks are below (if you do not see any, please add `require 'glimmer/rake_task'` to Rakefile and rerun or run rake -T):
|
27
|
+
|
34
28
|
MULTI_LINE_STRING
|
35
29
|
|
36
30
|
GLIMMER_LIB_LOCAL = File.expand_path(File.join('lib', 'glimmer-dsl-swt.rb'))
|
@@ -73,6 +67,10 @@ module Glimmer
|
|
73
67
|
end
|
74
68
|
@glimmer_lib
|
75
69
|
end
|
70
|
+
|
71
|
+
def dev_mode?
|
72
|
+
glimmer_lib == GLIMMER_LIB_LOCAL
|
73
|
+
end
|
76
74
|
|
77
75
|
def glimmer_option_env_vars(glimmer_options)
|
78
76
|
GLIMMER_OPTION_ENV_VAR_MAPPING.reduce({}) do |hash, pair|
|
@@ -89,12 +87,19 @@ module Glimmer
|
|
89
87
|
def launch(application, jruby_options: [], env_vars: {}, glimmer_options: {})
|
90
88
|
jruby_options_string = jruby_options.join(' ') + ' ' if jruby_options.any?
|
91
89
|
env_vars = env_vars.merge(glimmer_option_env_vars(glimmer_options))
|
92
|
-
env_vars_string = env_vars.map
|
90
|
+
env_vars_string = env_vars.map do |k,v|
|
91
|
+
if OS.windows? && ENV['PROMPT'] # detect command prompt (or powershell)
|
92
|
+
"set #{k}=#{v} && "
|
93
|
+
else
|
94
|
+
"export #{k}=#{v} && "
|
95
|
+
end
|
96
|
+
end.join
|
93
97
|
the_glimmer_lib = glimmer_lib
|
94
98
|
devmode_require = nil
|
95
99
|
if the_glimmer_lib == GLIMMER_LIB_LOCAL
|
96
100
|
devmode_require = '-r puts_debuggerer '
|
97
101
|
end
|
102
|
+
require_relative 'rake_task'
|
98
103
|
rake_tasks = Rake.application.tasks.map(&:to_s).map {|t| t.sub('glimmer:', '')}
|
99
104
|
|
100
105
|
# handle a bash quirk with calling package[msi] while there is a "packages" directory locally (it passes package[msi] as packages)
|
@@ -113,8 +118,16 @@ module Glimmer
|
|
113
118
|
puts "Launching Glimmer Application: #{application}" if jruby_options_string.to_s.include?('--debug') || glimmer_options['--quiet'].to_s.downcase != 'true'
|
114
119
|
end
|
115
120
|
command = "#{env_vars_string} jruby #{jruby_options_string}#{jruby_os_specific_options} #{devmode_require}-r #{the_glimmer_lib} -S #{application}"
|
121
|
+
if !env_vars_string.empty? && OS.windows?
|
122
|
+
command = "bash -c \"#{command}\"" if ENV['SHELL'] # do in Windows Git Bash only
|
123
|
+
command = "cmd /C \"#{command}\"" if ENV['PROMPT'] # do in Windows Command Prompt only (or Powershell)
|
124
|
+
end
|
116
125
|
puts command if jruby_options_string.to_s.include?('--debug')
|
117
|
-
|
126
|
+
if command.include?(' irb ')
|
127
|
+
exec command
|
128
|
+
else
|
129
|
+
system command
|
130
|
+
end
|
118
131
|
end
|
119
132
|
end
|
120
133
|
end
|
@@ -159,10 +172,35 @@ module Glimmer
|
|
159
172
|
end
|
160
173
|
|
161
174
|
def display_usage
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
175
|
+
puts TEXT_USAGE
|
176
|
+
display_tasks
|
177
|
+
end
|
178
|
+
|
179
|
+
def display_tasks
|
180
|
+
if OS.windows?
|
181
|
+
tasks = Rake.application.tasks
|
182
|
+
task_lines = tasks.reject do |task|
|
183
|
+
task.comment.nil?
|
184
|
+
end.map do |task|
|
185
|
+
max_task_size = tasks.map(&:name_with_args).map(&:size).max + 1
|
186
|
+
task_name = task.name_with_args.sub('glimmer:', '')
|
187
|
+
line = "glimmer #{task_name.ljust(max_task_size)} # #{task.comment}"
|
188
|
+
bound = TTY::Screen.width - 6
|
189
|
+
line.size <= bound ? line : "#{line[0..(bound - 3)]}..."
|
190
|
+
end
|
191
|
+
puts task_lines.to_a
|
192
|
+
else
|
193
|
+
require 'rake-tui'
|
194
|
+
require 'tty-screen'
|
195
|
+
require_relative 'rake_task'
|
196
|
+
Rake::TUI.run(branding_header: nil, prompt_question: 'Select a Glimmer task to run:') do |task, tasks|
|
197
|
+
max_task_size = tasks.map(&:name_with_args).map(&:size).max + 1
|
198
|
+
task_name = task.name_with_args.sub('glimmer:', '')
|
199
|
+
line = "glimmer #{task_name.ljust(max_task_size)} # #{task.comment}"
|
200
|
+
bound = TTY::Screen.width - 6
|
201
|
+
line.size <= bound ? line : "#{line[0..(bound - 3)]}..."
|
202
|
+
end
|
203
|
+
end
|
166
204
|
end
|
167
205
|
|
168
206
|
def extract_application_paths(options)
|
data/lib/glimmer/rake_task.rb
CHANGED
@@ -2,7 +2,95 @@ require 'rake'
|
|
2
2
|
|
3
3
|
require_relative 'package'
|
4
4
|
|
5
|
+
ENV['GLIMMER_LOGGER_ENABLED'] = 'false'
|
6
|
+
require_relative '../ext/glimmer/config.rb'
|
7
|
+
|
8
|
+
Glimmer::Config::SAMPLE_DIRECTORIES << File.expand_path('../../../samples/hello', __FILE__)
|
9
|
+
Glimmer::Config::SAMPLE_DIRECTORIES << File.expand_path('../../../samples/elaborate', __FILE__)
|
10
|
+
|
5
11
|
namespace :glimmer do
|
12
|
+
namespace :sample do
|
13
|
+
task :requires do
|
14
|
+
require 'text-table'
|
15
|
+
require 'facets/string/titlecase'
|
16
|
+
require 'facets/string/underscore'
|
17
|
+
|
18
|
+
require_relative 'launcher'
|
19
|
+
end
|
20
|
+
|
21
|
+
task :glimmer_gems do
|
22
|
+
glimmer_gem_lib_files = Dir.glob(File.join(Gem.dir, 'gems', '*')).to_a.select do |gem_path|
|
23
|
+
!!File.basename(gem_path).match(/glimmer-cw|glimmer-cs|glimmer-dsl/)
|
24
|
+
end.map do |gem_path|
|
25
|
+
Dir.glob(File.join(gem_path, 'lib/*.rb')).detect {|lib| gem_path.include?(File.basename(lib, '.rb')) }
|
26
|
+
end.uniq do |gem_lib_file|
|
27
|
+
File.basename(gem_lib_file)
|
28
|
+
end
|
29
|
+
glimmer_gem_lib_files.each {|file| require file.sub(/\.rb$/, '')}
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples.'
|
33
|
+
task :run, [:name] => [:requires, :glimmer_gems] do |t, args|
|
34
|
+
name = args[:name]
|
35
|
+
name = name.underscore.downcase unless name.nil?
|
36
|
+
samples = Glimmer::Config::SAMPLE_DIRECTORIES.map {|dir| Dir.glob(File.join(dir, '*.rb'))}.reduce(:+).sort
|
37
|
+
samples = samples.select {|path| path.include?("#{name}.rb")} unless name.nil?
|
38
|
+
Rake::Task['glimmer:sample:code'].invoke(name) if samples.size == 1
|
39
|
+
Glimmer::Launcher.new(samples << '--quiet=false').launch
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'Lists Glimmer internal samples [included in gem]. Filters by query if specified (query is optional)'
|
43
|
+
task :list, [:query] => [:requires, :glimmer_gems] do |t, args|
|
44
|
+
Glimmer::Config::SAMPLE_DIRECTORIES.each do |dir|
|
45
|
+
sample_group_name = File.basename(dir)
|
46
|
+
human_sample_group_name = sample_group_name.underscore.titlecase
|
47
|
+
array_of_arrays = Dir.glob(File.join(dir, '*.rb')).map do |path|
|
48
|
+
File.basename(path, '.rb')
|
49
|
+
end.select do |path|
|
50
|
+
args[:query].nil? || path.include?(args[:query])
|
51
|
+
end.map do |path|
|
52
|
+
[path, path.underscore.titlecase, "#{'bin/' if Glimmer::Launcher.dev_mode?}glimmer sample:run[#{path}]"]
|
53
|
+
end.sort
|
54
|
+
if array_of_arrays.empty?
|
55
|
+
puts "No Glimmer #{human_sample_group_name} Samples match the query."
|
56
|
+
else
|
57
|
+
puts
|
58
|
+
puts " Glimmer #{human_sample_group_name} Samples:"
|
59
|
+
puts Text::Table.new(
|
60
|
+
:head => %w[Name Description Run],
|
61
|
+
:rows => array_of_arrays,
|
62
|
+
:horizontal_padding => 1,
|
63
|
+
:vertical_boundary => ' ',
|
64
|
+
:horizontal_boundary => ' ',
|
65
|
+
:boundary_intersection => ' '
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'Outputs code for a Glimmer internal sample [included in gem] (name is required)'
|
72
|
+
task :code, [:name] => [:requires, :glimmer_gems] do |t, args|
|
73
|
+
require 'tty-markdown' unless OS.windows?
|
74
|
+
samples = Glimmer::Config::SAMPLE_DIRECTORIES.map {|dir| Dir.glob(File.join(dir, '*.rb'))}.reduce(:+).sort
|
75
|
+
sample = samples.detect {|path| path.include?("#{args[:name].to_s.underscore.downcase}.rb")}
|
76
|
+
sample_additional_files = Dir.glob(File.join(sample.sub('.rb', ''), '**', '*.rb'))
|
77
|
+
code = ([sample] + sample_additional_files).map do |file|
|
78
|
+
<<~RUBY
|
79
|
+
|
80
|
+
# #{file}
|
81
|
+
|
82
|
+
#{File.read(file)}
|
83
|
+
|
84
|
+
# # #
|
85
|
+
|
86
|
+
RUBY
|
87
|
+
end.join("\n")
|
88
|
+
code = TTY::Markdown.parse("```ruby\n#{code}\n```") unless OS.windows?
|
89
|
+
puts code
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
6
94
|
namespace :package do
|
7
95
|
desc 'Clean by removing "dist" and "packages" directories'
|
8
96
|
task :clean do
|
@@ -40,7 +128,6 @@ namespace :glimmer do
|
|
40
128
|
Rake::Task['glimmer:package:native'].execute(args)
|
41
129
|
end
|
42
130
|
|
43
|
-
|
44
131
|
desc 'Scaffold Glimmer application directory structure to build a new app'
|
45
132
|
task :scaffold, [:app_name] do |t, args|
|
46
133
|
require_relative 'scaffold'
|
data/lib/glimmer/scaffold.rb
CHANGED
@@ -4,6 +4,8 @@ require 'facets'
|
|
4
4
|
|
5
5
|
# TODO refactor to nest under RakeTask namespace
|
6
6
|
|
7
|
+
MAIN_OBJECT = self
|
8
|
+
|
7
9
|
class Scaffold
|
8
10
|
class << self
|
9
11
|
include FileUtils
|
@@ -179,6 +181,13 @@ class Scaffold
|
|
179
181
|
def custom_shell_gem(custom_shell_name, namespace)
|
180
182
|
gem_name = "glimmer-cs-#{compact_name(custom_shell_name)}"
|
181
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
|
182
191
|
if namespace
|
183
192
|
gem_name += "-#{compact_name(namespace)}"
|
184
193
|
gem_summary += " (#{human_name(namespace)})"
|
@@ -350,12 +359,19 @@ class Scaffold
|
|
350
359
|
end
|
351
360
|
|
352
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
|
353
363
|
<<~MULTI_LINE_STRING
|
354
364
|
require_relative '../lib/#{gem_name}'
|
355
365
|
|
356
|
-
|
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
|
357
373
|
|
358
|
-
#{
|
374
|
+
#{class_name(custom_shell_name)}App.new.open
|
359
375
|
MULTI_LINE_STRING
|
360
376
|
end
|
361
377
|
|
@@ -394,7 +410,7 @@ class Scaffold
|
|
394
410
|
" -name '#{human_name(custom_shell_name)}'" +
|
395
411
|
" -title '#{human_name(custom_shell_name)}'" +
|
396
412
|
" -Bmac.CFBundleName='#{human_name(custom_shell_name)}'" +
|
397
|
-
" -Bmac.CFBundleIdentifier='org.#{namespace ? compact_name(namespace) : compact_name(custom_shell_name)}.application.#{compact_name(custom_shell_name)}'"
|
413
|
+
" -Bmac.CFBundleIdentifier='org.#{namespace ? compact_name(namespace) : compact_name(custom_shell_name)}.application.#{compact_name(custom_shell_name).capitalize}'"
|
398
414
|
# " -BlicenseType=" +
|
399
415
|
# " -Bmac.category=" +
|
400
416
|
# " -Bmac.signing-key-developer-id-app="
|
@@ -209,9 +209,19 @@ module Glimmer
|
|
209
209
|
@editor = args
|
210
210
|
end
|
211
211
|
|
212
|
+
def cells_for(model)
|
213
|
+
column_properties.map {|property| model.send(property)}
|
214
|
+
end
|
215
|
+
|
216
|
+
def cells
|
217
|
+
column_count = @table.column_properties.size
|
218
|
+
swt_widget.items.map {|item| column_count.times.map {|i| item.get_text(i)} }
|
219
|
+
end
|
220
|
+
|
212
221
|
def sort
|
213
222
|
return unless sort_property && (sort_type || sort_block || sort_by_block)
|
214
223
|
array = model_binding.evaluate_property
|
224
|
+
array = array.sort_by(&:hash) # this ensures consistent subsequent sorting in case there are equivalent sorts to avoid an infinite loop
|
215
225
|
# Converting value to_s first to handle nil cases. Should work with numeric, boolean, and date fields
|
216
226
|
if sort_block
|
217
227
|
sorted_array = array.sort(&sort_block)
|