glimmer-dsl-swt 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d54a8793938853e74eb207e159ce6ab3f856ac57f737a3bd28990f5e52a745d
4
- data.tar.gz: a28121a29d1a123b056d121642bf70acd12891c428bdda8602caa2cf7157df35
3
+ metadata.gz: c4290c2587a5d74bdbd39df1e1459219628abd0f867df9c972ec766d1581e786
4
+ data.tar.gz: a422f8c8f1cad97b8c59f72eefdbdac2bfab5076e45b4d99bacbea063f683897
5
5
  SHA512:
6
- metadata.gz: 21a850f6805c1cc2f129bdc91c09c7a8b336ce81640311af63040c8168d535ab68fb91cb53bf0a8421ec38d1daab94b9a835eec209e2685e1702ca3e91b51af8
7
- data.tar.gz: 3044e95046bbda195c0ecd736ff30097ab6dadf660093d317d86d92c46f1bdf16dc669f944a9a62b398fa2f27697572290f4df9caffb8825c6b61a8f0ff2fea1
6
+ metadata.gz: cfe72e5b9043ca482199ebcdb21ce5dfb3bcf5106b4adf2d1f5928d195b9ae99fbd1cd10b120ec14901052121a3cb82e5e45a203e235daaf2bd29addc6e29f60
7
+ data.tar.gz: 9f1d1bd197e61a8a462f5afc8d84466b0a595f0ab225999571d9fb22c8f00e078928a675a4474fde34c1274aaac252c4d23f7c7fcd38fea155a0cac8e6769767
data/README.md CHANGED
@@ -1,4 +1,4 @@
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.2 (Desktop GUI)
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.3 (Desktop GUI)
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
3
3
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
4
4
  [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-swt/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-swt?branch=master)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.2
1
+ 0.6.3
data/bin/girb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env jruby
2
2
 
3
3
  trap "SIGINT" do
4
4
  # No Op for irb
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env jruby
2
2
 
3
3
  require_relative '../lib/glimmer/launcher'
4
4
 
Binary file
@@ -16,7 +16,15 @@ module Glimmer
16
16
 
17
17
  def interpret(parent, keyword, *args, &block)
18
18
  potential_parent = args.first
19
- parent = args.shift if potential_parent.is_a?(Shell) || (potential_parent.respond_to?(:swt_widget) && potential_parent.swt_widget.is_a?(Shell))
19
+ potential_parent = potential_parent.swt_widget if potential_parent.respond_to?(:swt_widget)
20
+ parent = nil
21
+ if potential_parent.is_a?(Shell)
22
+ args.shift
23
+ parent = potential_parent
24
+ elsif potential_parent.is_a?(Widget)
25
+ args.shift
26
+ parent = potential_parent.shell
27
+ end
20
28
  Glimmer::SWT::MessageBoxProxy.new(parent, Glimmer::SWT::SWTProxy[args])
21
29
  end
22
30
  end
@@ -17,13 +17,7 @@ module Glimmer
17
17
  end
18
18
 
19
19
  def interpret(parent, keyword, *args, &block)
20
- begin
21
- class_name = "#{keyword.camelcase(:upper)}Proxy".to_sym
22
- widget_class = Glimmer::SWT.const_get(class_name)
23
- rescue
24
- widget_class = Glimmer::SWT::WidgetProxy
25
- end
26
- widget_class.new(keyword, parent, args)
20
+ Glimmer::SWT::WidgetProxy.create(keyword, parent, args)
27
21
  end
28
22
 
29
23
  def add_content(parent, &block)
@@ -13,7 +13,7 @@ module Glimmer
13
13
 
14
14
  When a task is specified, it runs via rake. Some tasks take arguments in square brackets.
15
15
 
16
- Available tasks are below (you may also lookup by adding `require 'glimmer/rake_task'` in Rakefile and running rake -T):
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
17
  MULTI_LINE_STRING
18
18
 
19
19
  TEXT_USAGE_SUFFIX = <<~MULTI_LINE_STRING
@@ -96,6 +96,10 @@ module Glimmer
96
96
  devmode_require = '-r puts_debuggerer '
97
97
  end
98
98
  rake_tasks = Rake.application.tasks.map(&:to_s).map {|t| t.sub('glimmer:', '')}
99
+
100
+ # handle a bash quirk with calling package[msi] while there is a "packages" directory locally (it passes package[msi] as packages)
101
+ application = 'package[msi]' if application == 'packages'
102
+
99
103
  potential_rake_task_parts = application.match(REGEX_RAKE_TASK_WITH_ARGS)
100
104
  application = potential_rake_task_parts[1]
101
105
  rake_task_args = potential_rake_task_parts[2].split(',')
@@ -6,6 +6,7 @@ module Glimmer
6
6
  module Package
7
7
  class << self
8
8
  attr_accessor :javapackager_extra_args
9
+ alias jpackage_extra_args :javapackager_extra_args
9
10
 
10
11
  def clean
11
12
  require 'fileutils'
@@ -42,14 +43,15 @@ module Glimmer
42
43
  end
43
44
 
44
45
  def lock_jars
45
- puts 'Locking JARs with jar-dependencies...'
46
- command = "lock_jars --vendor-dir vendor"
46
+ puts 'Locking gem jar-dependencies by downloading & storing in vendor/jars...'
47
+ FileUtils.mkdir_p('vendor/jars')
48
+ command = "lock_jars --vendor-dir vendor/jars"
47
49
  puts command
48
50
  system command
49
51
  end
50
52
 
51
- def native(native_type=nil)
52
- puts "Generating native executable with javapackager..."
53
+ def native(native_type=nil, native_extra_args)
54
+ puts "Generating native executable with javapackager/jpackage..."
53
55
  require 'facets/string/titlecase'
54
56
  require 'facets/string/underscore'
55
57
  project_name = File.basename(File.expand_path('.'))
@@ -59,13 +61,28 @@ module Glimmer
59
61
  license = (File.read(license_file).strip if File.exists?(license_file) && File.file?(license_file)) rescue nil
60
62
  copyright = license.split("\n").first
61
63
  human_name = project_name.underscore.titlecase
62
- command = "javapackager -deploy -native #{native_type} -outdir packages -outfile \"#{project_name}\" -srcfiles \"dist/#{project_name}.jar\" -appclass JarMain -name \"#{human_name}\" -title \"#{human_name}\" -Bmac.CFBundleName=\"#{human_name}\" -Bmac.CFBundleIdentifier=\"org.#{project_name}.application.#{project_name}\" -Bmac.category=\"public.app-category.business\" -BinstalldirChooser=true -Bvendor=\"#{human_name}\" -Bwin.menuGroup=\"#{human_name}\" -BsystemWide=#{OS.mac?} "
63
- command += " -BjvmOptions=-XstartOnFirstThread " if OS.mac?
64
- command += " -BappVersion=#{version} -Bmac.CFBundleVersion=#{version} " if version
65
- command += " -srcfiles LICENSE.txt -BlicenseFile=LICENSE.txt " if license
66
- command += " -Bcopyright=\"#{copyright}\" " if copyright
64
+ icon = "package/#{OS.mac? ? 'macosx' : 'windows'}/#{human_name}.#{OS.mac? ? 'icns' : 'ico'}"
65
+ if (`javapackager`.to_s.include?('Usage: javapackager') rescue nil)
66
+ command = "javapackager -deploy -native #{native_type} -outdir packages -outfile \"#{project_name}\" -srcfiles \"dist/#{project_name}.jar\" -appclass JarMain -name \"#{human_name}\" -title \"#{human_name}\" -Bmac.CFBundleName=\"#{human_name}\" -Bmac.CFBundleIdentifier=\"org.#{project_name}.application.#{project_name}\" -Bmac.category=\"public.app-category.business\" -BinstalldirChooser=true -Bvendor=\"#{human_name}\" -Bwin.menuGroup=\"#{human_name}\" "
67
+ command += " -BsystemWide=false " if OS.windows?
68
+ command += " -BjvmOptions=-XstartOnFirstThread " if OS.mac?
69
+ command += " -BappVersion=#{version} -Bmac.CFBundleVersion=#{version} " if version
70
+ command += " -srcfiles LICENSE.txt -BlicenseFile=LICENSE.txt " if license
71
+ command += " -Bcopyright=\"#{copyright}\" " if copyright
72
+ elsif (`jpackage`.to_s.include?('Usage: jpackage') rescue nil)
73
+ command = "jpackage --type #{native_type} --dest 'packages/bundles' --input 'dist' --main-class JarMain --main-jar '#{project_name}.jar' --name '#{human_name}' --vendor '#{human_name}' --icon '#{icon}' "
74
+ command += " --win-per-user-install --win-dir-chooser --win-menu --win-menu-group '#{human_name}' " if OS.windows?
75
+ command += " --java-options '-XstartOnFirstThread' --mac-package-name '#{human_name}' --mac-package-identifier 'org.#{project_name}.application.#{project_name}' " if OS.mac?
76
+ command += " --app-version \"#{version}\" " if version
77
+ command += " --license-file LICENSE.txt " if license
78
+ command += " --copyright \"#{copyright}\" " if copyright
79
+ else
80
+ puts "Neither javapackager nor jpackage exist in your Java installation. Please ensure javapackager or jpackage is available in PATH environment variable."
81
+ return
82
+ end
67
83
  command += " #{javapackager_extra_args} " if javapackager_extra_args
68
84
  command += " #{ENV['JAVAPACKAGER_EXTRA_ARGS']} " if ENV['JAVAPACKAGER_EXTRA_ARGS']
85
+ command += " #{native_extra_args} " if native_extra_args
69
86
  puts command
70
87
  system command
71
88
  end
@@ -24,18 +24,19 @@ namespace :glimmer do
24
24
  Glimmer::Package.lock_jars
25
25
  end
26
26
 
27
- desc 'Generate Native files (DMG/PKG/APP on the Mac, MSI/EXE/IMAGE on Windows, RPM/DEB on Linux) (type is optional)'
27
+ desc 'Generate Native files. type can be dmg/pkg on the Mac, msi/exe on Windows, and rpm/deb on Linux (type is optional)'
28
28
  task :native, [:type] do |t, args|
29
- Glimmer::Package.native(args[:type])
29
+ extra_args = ARGV.partition {|arg| arg.include?('package:native')}.last.to_a.join(' ')
30
+ Glimmer::Package.native(args[:type], extra_args)
30
31
  end
31
32
  end
32
33
 
33
34
  desc 'Package app for distribution (generating config, jar, and native files) (type is optional)'
34
35
  task :package, [:type] do |t, args|
36
+ Rake::Task['gemspec:generate'].execute
37
+ Rake::Task['glimmer:package:lock_jars'].execute
35
38
  Rake::Task['glimmer:package:config'].execute
36
39
  Rake::Task['glimmer:package:jar'].execute
37
- Rake::Task['glimmer:package:lock_jars'].execute
38
- Rake::Task['gemspec:generate'].execute
39
40
  Rake::Task['glimmer:package:native'].execute(args)
40
41
  end
41
42
 
@@ -73,7 +73,8 @@ class Scaffold
73
73
 
74
74
  # Glimmer
75
75
  dist
76
- packages
76
+ packages
77
+ vendor/jars
77
78
  MULTI_LINE_STRING
78
79
 
79
80
  GEMFILE = <<~MULTI_LINE_STRING
@@ -109,7 +110,6 @@ class Scaffold
109
110
  MULTI_LINE_STRING
110
111
 
111
112
  def app(app_name)
112
- return puts('Namespace is required! Usage: glimmer scaffold:custom_shell_gem[custom_shell_name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
113
113
  gem_name = file_name(app_name)
114
114
  gem_summary = human_name(app_name)
115
115
  system "jruby -r git-glimmer -S jeweler --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
@@ -127,17 +127,22 @@ class Scaffold
127
127
  mkdir 'app/models'
128
128
  mkdir 'app/views'
129
129
  custom_shell('AppView', current_dir_name, :app)
130
- if OS::Underlying.windows?
131
- mkdir_p 'package/windows'
132
- icon_file = "package/windows/#{human_name(app_name)}.ico"
133
- cp File.expand_path('../../../icons/scaffold_app.ico', __FILE__), icon_file
134
- puts "Created #{current_dir_name}/#{icon_file}"
135
- elsif OS.mac?
136
- mkdir_p 'package/macosx'
137
- icon_file = "package/macosx/#{human_name(app_name)}.icns"
138
- cp File.expand_path('../../../icons/scaffold_app.icns', __FILE__), icon_file
139
- puts "Created #{current_dir_name}/#{icon_file}"
140
- end
130
+
131
+ mkdir_p 'package/windows'
132
+ icon_file = "package/windows/#{human_name(app_name)}.ico"
133
+ cp File.expand_path('../../../icons/scaffold_app.ico', __FILE__), icon_file
134
+ puts "Created #{current_dir_name}/#{icon_file}"
135
+
136
+ mkdir_p 'package/macosx'
137
+ icon_file = "package/macosx/#{human_name(app_name)}.icns"
138
+ cp File.expand_path('../../../icons/scaffold_app.icns', __FILE__), icon_file
139
+ puts "Created #{current_dir_name}/#{icon_file}"
140
+
141
+ mkdir_p 'package/linux'
142
+ icon_file = "package/linux/#{human_name(app_name)}.png"
143
+ cp File.expand_path('../../../icons/scaffold_app.png', __FILE__), icon_file
144
+ puts "Created #{current_dir_name}/#{icon_file}"
145
+
141
146
  mkdir 'bin'
142
147
  write "bin/#{file_name(app_name)}", app_bin_file(app_name)
143
148
  write 'spec/spec_helper.rb', spec_helper_file
@@ -147,9 +152,12 @@ class Scaffold
147
152
  system "\"packages/bundles/#{human_name(app_name)}/#{human_name(app_name)}.exe\""
148
153
  else
149
154
  system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n glimmer package\n'"
150
- system "open packages/bundles/#{human_name(app_name).gsub(' ', '\ ')}.app" if OS.mac?
155
+ if OS.mac?
156
+ system "open packages/bundles/#{human_name(app_name).gsub(' ', '\ ')}.app"
157
+ else
158
+ system "glimmer bin/#{file_name(app_name)}"
159
+ end
151
160
  end
152
- # TODO generate rspec test suite
153
161
  end
154
162
 
155
163
  def custom_shell(custom_shell_name, namespace, shell_type = nil)
@@ -169,13 +177,13 @@ class Scaffold
169
177
  end
170
178
 
171
179
  def custom_shell_gem(custom_shell_name, namespace)
172
- return puts('Namespace is required! Usage: glimmer scaffold:custom_shell_gem[custom_shell_name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
173
180
  gem_name = "glimmer-cs-#{compact_name(custom_shell_name)}"
174
181
  gem_summary = "#{human_name(custom_shell_name)} - Glimmer Custom Shell"
175
182
  if namespace
176
183
  gem_name += "-#{compact_name(namespace)}"
177
184
  gem_summary += " (#{human_name(namespace)})"
178
185
  else
186
+ return puts('Namespace is required! Usage: glimmer scaffold:gem:customshell[name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
179
187
  namespace = 'glimmer'
180
188
  end
181
189
  system "jruby -r git-glimmer -S jeweler --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
@@ -194,24 +202,33 @@ class Scaffold
194
202
  write "bin/#{file_name(custom_shell_name)}", gem_bin_command_file(gem_name)
195
203
  FileUtils.chmod 0755, "bin/#{file_name(custom_shell_name)}"
196
204
  write 'spec/spec_helper.rb', spec_helper_file
197
- if OS::Underlying.windows?
198
- mkdir_p 'package/windows'
199
- icon_file = "package/windows/#{human_name(custom_shell_name)}.ico"
200
- cp File.expand_path('../../../icons/scaffold_app.ico', __FILE__), icon_file
201
- puts "Created #{current_dir_name}/#{icon_file}"
202
- elsif OS.mac?
203
- mkdir_p 'package/macosx'
204
- icon_file = "package/macosx/#{human_name(custom_shell_name)}.icns"
205
- cp File.expand_path('../../../icons/scaffold_app.icns', __FILE__), icon_file
206
- puts "Created #{current_dir_name}/#{icon_file}"
207
- end
205
+
206
+ mkdir_p 'package/windows'
207
+ icon_file = "package/windows/#{human_name(custom_shell_name)}.ico"
208
+ cp File.expand_path('../../../icons/scaffold_app.ico', __FILE__), icon_file
209
+ puts "Created #{current_dir_name}/#{icon_file}"
210
+
211
+ mkdir_p 'package/macosx'
212
+ icon_file = "package/macosx/#{human_name(custom_shell_name)}.icns"
213
+ cp File.expand_path('../../../icons/scaffold_app.icns', __FILE__), icon_file
214
+ puts "Created #{current_dir_name}/#{icon_file}"
215
+
216
+ mkdir_p 'package/linux'
217
+ icon_file = "package/linux/#{human_name(custom_shell_name)}.png"
218
+ cp File.expand_path('../../../icons/scaffold_app.png', __FILE__), icon_file
219
+ puts "Created #{current_dir_name}/#{icon_file}"
220
+
208
221
  if OS.windows?
209
222
  system "bundle"
210
223
  system "glimmer package[image]"
211
224
  system "\"packages/bundles/#{human_name(custom_shell_name)}/#{human_name(custom_shell_name)}.exe\""
212
225
  else
213
226
  system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n glimmer package\n'"
214
- system "open packages/bundles/#{human_name(custom_shell_name).gsub(' ', '\ ')}.app" if OS.mac?
227
+ if OS.mac?
228
+ system "open packages/bundles/#{human_name(custom_shell_name).gsub(' ', '\ ')}.app" if OS.mac?
229
+ else
230
+ system "bin/#{file_name(custom_shell_name)}"
231
+ end
215
232
  end
216
233
  puts "Finished creating #{gem_name} Ruby gem."
217
234
  puts 'Edit Rakefile to configure gem details.'
@@ -344,7 +361,7 @@ class Scaffold
344
361
 
345
362
  def gem_bin_command_file(gem_name)
346
363
  <<~MULTI_LINE_STRING
347
- #!/usr/bin/env ruby
364
+ #!/usr/bin/env jruby
348
365
 
349
366
  require 'glimmer/launcher'
350
367
 
@@ -489,7 +506,7 @@ class Scaffold
489
506
  menu {
490
507
  text '&File'
491
508
  menu_item {
492
- text 'Preferences...'
509
+ text '&Preferences...'
493
510
  on_widget_selected {
494
511
  display_preferences_dialog
495
512
  }
@@ -35,16 +35,26 @@ module Glimmer
35
35
  @swt_display = Display.new(*args)
36
36
  @swt_display.set_data('proxy', self)
37
37
  end
38
+
39
+ def content(&block)
40
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::DisplayExpression.new, &block)
41
+ end
38
42
 
39
43
  def method_missing(method, *args, &block)
40
- swt_display.send(method, *args, &block)
44
+ if can_handle_observation_request?(method)
45
+ handle_observation_request(method, &block)
46
+ else
47
+ swt_display.send(method, *args, &block)
48
+ end
41
49
  rescue => e
42
50
  Glimmer::Config.logger.debug {"Neither DisplayProxy nor #{swt_display.class.name} can handle the method ##{method}"}
43
51
  super
44
52
  end
45
53
 
46
54
  def respond_to?(method, *args, &block)
47
- super || swt_display.respond_to?(method, *args, &block)
55
+ super ||
56
+ can_handle_observation_request?(method) ||
57
+ swt_display.respond_to?(method, *args, &block)
48
58
  end
49
59
 
50
60
  def can_handle_observation_request?(observation_request)
@@ -61,6 +71,7 @@ module Glimmer
61
71
  end
62
72
 
63
73
  def handle_observation_request(observation_request, &block)
74
+ observation_request = observation_request.to_s
64
75
  if observation_request.start_with?('on_swt_')
65
76
  constant_name = observation_request.sub(/^on_swt_/, '')
66
77
  add_swt_event_listener(constant_name, &block)
@@ -14,16 +14,22 @@ module Glimmer
14
14
  attr_reader :swt_widget
15
15
 
16
16
  def initialize(parent, style)
17
- parent = parent.swt_widget if parent.respond_to?(:swt_widget) && parent.swt_widget.is_a?(Shell)
18
- @temporary_parent = parent = Glimmer::SWT::ShellProxy.new.swt_widget if parent.nil?
19
- @swt_widget = MessageBox.new(parent, style)
17
+ if parent.nil?
18
+ @temporary_parent = parent = Glimmer::SWT::ShellProxy.new.swt_widget
19
+ end
20
+ @swt_widget = MessageBox.new(parent, style)
20
21
  end
21
22
 
22
23
  def open
23
- @swt_widget.open
24
- @temporary_parent&.dispose
24
+ @swt_widget.open.tap do |result|
25
+ @temporary_parent&.dispose
26
+ end
25
27
  end
26
28
 
29
+ def content(&block)
30
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::MessageBoxExpression.new, &block)
31
+ end
32
+
27
33
  # TODO refactor the following methods to put in a JavaBean mixin or somethin (perhaps contribute to OSS project too)
28
34
 
29
35
  def attribute_setter(attribute_name)
@@ -44,6 +50,18 @@ module Glimmer
44
50
 
45
51
  def get_attribute(attribute_name)
46
52
  @swt_widget.send(attribute_getter(attribute_name))
53
+ end
54
+
55
+ def method_missing(method, *args, &block)
56
+ swt_widget.send(method, *args, &block)
57
+ rescue => e
58
+ Glimmer::Config.logger.debug {"Neither MessageBoxProxy nor #{swt_widget.class.name} can handle the method ##{method}"}
59
+ super
60
+ end
61
+
62
+ def respond_to?(method, *args, &block)
63
+ super ||
64
+ swt_widget.respond_to?(method, *args, &block)
47
65
  end
48
66
  end
49
67
  end
@@ -85,7 +85,55 @@ module Glimmer
85
85
  }
86
86
  table_editor_widget_proxy
87
87
  end,
88
- }
88
+ },
89
+ checkbox: {
90
+ widget_value_property: :selection,
91
+ editor_gui: lambda do |args, model, property, table_proxy|
92
+ first_time = true
93
+ table_proxy.table_editor.minimumHeight = 25
94
+ checkbox(*args) {
95
+ selection model.send(property)
96
+ focus true
97
+ on_widget_selected {
98
+ table_proxy.finish_edit!
99
+ }
100
+ on_focus_lost {
101
+ table_proxy.finish_edit!
102
+ }
103
+ on_key_pressed { |key_event|
104
+ if key_event.keyCode == swt(:cr)
105
+ table_proxy.finish_edit!
106
+ elsif key_event.keyCode == swt(:esc)
107
+ table_proxy.cancel_edit!
108
+ end
109
+ }
110
+ }
111
+ end,
112
+ },
113
+ radio: {
114
+ widget_value_property: :selection,
115
+ editor_gui: lambda do |args, model, property, table_proxy|
116
+ first_time = true
117
+ table_proxy.table_editor.minimumHeight = 25
118
+ radio(*args) {
119
+ selection model.send(property)
120
+ focus true
121
+ on_widget_selected {
122
+ table_proxy.finish_edit!
123
+ }
124
+ on_focus_lost {
125
+ table_proxy.finish_edit!
126
+ }
127
+ on_key_pressed { |key_event|
128
+ if key_event.keyCode == swt(:cr)
129
+ table_proxy.finish_edit!
130
+ elsif key_event.keyCode == swt(:esc)
131
+ table_proxy.cancel_edit!
132
+ end
133
+ }
134
+ }
135
+ end,
136
+ }
89
137
  }
90
138
  end
91
139
  end
@@ -276,7 +324,7 @@ module Glimmer
276
324
  new_value = @table_editor_widget_proxy&.swt_widget&.send(widget_value_property)
277
325
  if table_item.isDisposed
278
326
  @cancel_edit.call
279
- elsif new_value && !action_taken && !@edit_in_progress && !@cancel_in_progress
327
+ elsif !new_value.nil? && !action_taken && !@edit_in_progress && !@cancel_in_progress
280
328
  action_taken = true
281
329
  @edit_in_progress = true
282
330
  if new_value == model.send(model_editing_property)
@@ -67,18 +67,45 @@ module Glimmer
67
67
  group.setLayout(GridLayout.new)
68
68
  end,
69
69
  }
70
+
71
+ class << self
72
+ def create(keyword, parent, args)
73
+ widget_proxy_class(keyword).new(keyword, parent, args)
74
+ end
75
+
76
+ def widget_proxy_class(keyword)
77
+ begin
78
+ class_name = "#{keyword.camelcase(:upper)}Proxy".to_sym
79
+ Glimmer::SWT.const_get(class_name)
80
+ rescue
81
+ Glimmer::SWT::WidgetProxy
82
+ end
83
+ end
84
+
85
+ def underscored_widget_name(swt_widget)
86
+ swt_widget.class.name.split(/::|\./).last.underscore
87
+ end
88
+ end
70
89
 
71
90
  attr_reader :parent_proxy, :swt_widget, :drag_source_proxy, :drop_target_proxy, :drag_source_style, :drag_source_transfer, :drop_target_transfer
72
91
 
73
92
  # Initializes a new SWT Widget
74
93
  #
75
94
  # Styles is a comma separate list of symbols representing SWT styles in lower case
76
- def initialize(underscored_widget_name, parent, args)
77
- @parent_proxy = parent
78
- styles, extra_options = extract_args(underscored_widget_name, args)
79
- swt_widget_class = self.class.swt_widget_class_for(underscored_widget_name)
80
- @swt_widget = swt_widget_class.new(@parent_proxy.swt_widget, style(underscored_widget_name, styles), *extra_options)
81
- @swt_widget.set_data('proxy', self)
95
+ def initialize(*init_args, swt_widget: nil)
96
+ if swt_widget.nil?
97
+ underscored_widget_name, parent, args = init_args
98
+ @parent_proxy = parent
99
+ styles, extra_options = extract_args(underscored_widget_name, args)
100
+ swt_widget_class = self.class.swt_widget_class_for(underscored_widget_name)
101
+ @swt_widget = swt_widget_class.new(@parent_proxy.swt_widget, style(underscored_widget_name, styles), *extra_options)
102
+ else
103
+ @swt_widget = swt_widget
104
+ underscored_widget_name = self.class.underscored_widget_name(@swt_widget)
105
+ parent_proxy_class = self.class.widget_proxy_class(self.class.underscored_widget_name(@swt_widget.parent))
106
+ @parent_proxy = parent_proxy_class.new(swt_widget: swt_widget.parent)
107
+ end
108
+ @swt_widget.set_data('proxy', self)
82
109
  DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@swt_widget)
83
110
  @parent_proxy.post_initialize_child(self)
84
111
  end
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-07 00:00:00.000000000 Z
11
+ date: 2020-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.10.1
18
+ version: 0.10.2
19
19
  name: glimmer
20
20
  type: :runtime
21
21
  prerelease: false
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.1
26
+ version: 0.10.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
@@ -57,7 +57,7 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 0.9.0
60
+ version: 0.10.0
61
61
  name: puts_debuggerer
62
62
  type: :runtime
63
63
  prerelease: false
@@ -65,7 +65,7 @@ dependencies:
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.9.0
68
+ version: 0.10.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
@@ -309,6 +309,7 @@ files:
309
309
  - bin/glimmer
310
310
  - icons/scaffold_app.icns
311
311
  - icons/scaffold_app.ico
312
+ - icons/scaffold_app.png
312
313
  - lib/ext/glimmer.rb
313
314
  - lib/ext/glimmer/config.rb
314
315
  - lib/glimmer-dsl-swt.rb