glimmer-dsl-swt 0.6.5 → 0.6.6

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: 8fa25c1d494d14eac00319e494d3b2f12c9a6b344c084b02a1dde9f60c2f44a5
4
- data.tar.gz: 648c050a1a25a284e972beb5c129047ef6cbf8fabb1a80981408d900afed0c25
3
+ metadata.gz: 2efe946d6209511675a9b2e91c76b71a69fa52ece7ea821229783c1ddf52c2da
4
+ data.tar.gz: 3df579040ae3a9183388d1b6d3bca864a911679973e33ff7faae8a421384f64a
5
5
  SHA512:
6
- metadata.gz: dc9dedb03e9251f0a88e5530a642c062899be1651b26d2314258925375b871a3e5736141a1ee5b8dfacde1bc7a1d606d4ce00ac8affc8bf160b06f4aa7141306
7
- data.tar.gz: 00416f75c6c00dc163501209a20839cd23fb51921a5335f8ffff7009bf013cca11ccb54389a55367c0ccbb1b0f1bb1641c61141d376a5c5792584567bd1d7937
6
+ metadata.gz: b3a057aabf006662881fa9adf157722831a4c6a2e397353a71b6c7d52fbc360bca96f095a5b5d4077bb271dd5b3eae9505cf8cd489bc801230179a8bf0d51aa8
7
+ data.tar.gz: ebe5556abe7c1dfe1446f2a42c0f71a799a47153b545f9cc463240d13a85bddf4c9e83eaab96e0b4f498de4753c48a8761306517714c19385a1d89c4e6f054d8
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.5 (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.6 (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)
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/aaf1cba142dd351f84bd/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-swt/maintainability)
6
6
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](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.5
1
+ 0.6.6
@@ -48,6 +48,10 @@ module Glimmer
48
48
 
49
49
  def logging_appender_options
50
50
  @@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
51
+ # TODO make this a glimmer command option
52
+ if ENV['GLIMMER_LOGGER_ASYNC'].to_s.downcase == 'false'
53
+ @@logging_appender_options.merge!(async: false, auto_flushing: 1, immediate_at: [:debug, :info, :warn, :error, :fatal])
54
+ end
51
55
  @@logging_appender_options
52
56
  end
53
57
 
@@ -90,9 +94,13 @@ module Glimmer
90
94
  end
91
95
  logger.appenders = appenders
92
96
  end
97
+
93
98
  end
99
+
94
100
  end
101
+
95
102
  end
103
+
96
104
  end
97
105
 
98
106
  Glimmer::Config.reset_logger!
@@ -2,15 +2,11 @@ $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
2
2
 
3
3
  # External requires
4
4
  require 'java'
5
- if ENV['BUNDLER_REQUIRE'].to_s.downcase == 'true'
6
- require 'bundler'
7
- Bundler.require
8
- else
9
- require 'glimmer'
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'
@@ -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)
@@ -84,18 +84,23 @@ namespace :glimmer do
84
84
 
85
85
  desc 'Outputs code for a Glimmer internal sample [included in gem] (name is required)'
86
86
  task :code, [:name] => :requires do |t, args|
87
+ require 'tty-markdown' unless OS.windows?
87
88
  samples = (Dir.glob(File.expand_path('../../../samples/hello/*.rb', __FILE__)) + Dir.glob(File.expand_path('../../../samples/elaborate/*.rb', __FILE__))).sort
88
89
  sample = samples.detect {|path| path.include?("#{args[:name].to_s.underscore.downcase}.rb")}
89
90
  sample_additional_files = Dir.glob(File.join(sample.sub('.rb', ''), '**', '*.rb'))
90
- ([sample] + sample_additional_files).each do |file|
91
- puts
92
- puts "# #{file}"
93
- puts
94
- puts File.read(file)
95
- puts
96
- puts '# # #'
97
- puts
98
- end
91
+ code = ([sample] + sample_additional_files).map do |file|
92
+ <<~RUBY
93
+
94
+ # #{file}
95
+
96
+ #{File.read(file)}
97
+
98
+ # # #
99
+
100
+ RUBY
101
+ end.join("\n")
102
+ code = TTY::Markdown.parse("```ruby\n#{code}\n```") unless OS.windows?
103
+ puts code
99
104
  end
100
105
 
101
106
  task :requires do
@@ -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
- include Glimmer
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
- #{dsl_widget_name(custom_shell_name)}.open
374
+ #{class_name(custom_shell_name)}App.new.open
359
375
  MULTI_LINE_STRING
360
376
  end
361
377
 
@@ -1,7 +1,6 @@
1
1
  require 'glimmer/swt/swt_proxy'
2
2
  require 'glimmer/swt/widget_proxy'
3
3
  require 'glimmer/swt/display_proxy'
4
- require 'glimmer/swt/swt_proxy'
5
4
 
6
5
  module Glimmer
7
6
  module SWT
@@ -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)
@@ -25,6 +25,7 @@ module Glimmer
25
25
  "arrow" => [:arrow],
26
26
  "button" => [:push],
27
27
  "checkbox" => [:check],
28
+ "check" => [:check],
28
29
  "drag_source" => [:drop_copy],
29
30
  "drop_target" => [:drop_copy],
30
31
  "list" => [:border, :v_scroll],
@@ -315,7 +316,7 @@ module Glimmer
315
316
 
316
317
  # This supports widgets in and out of basic SWT
317
318
  def self.swt_widget_class_for(underscored_widget_name)
318
- underscored_widget_name = 'button' if %w[radio checkbox toggle arrow].include?(underscored_widget_name)
319
+ underscored_widget_name = 'button' if %w[radio checkbox check toggle arrow].include?(underscored_widget_name)
319
320
  swt_widget_name = underscored_widget_name.camelcase(:upper)
320
321
  swt_widget_class = eval(swt_widget_name)
321
322
  unless swt_widget_class.ancestors.include?(org.eclipse.swt.widgets.Widget)
@@ -457,6 +458,7 @@ module Glimmer
457
458
  rescue => e
458
459
  Glimmer::Config.logger.debug {"Neither WidgetProxy nor #{swt_widget.class.name} can handle the method ##{method}"}
459
460
  super
461
+ # TODO consider get_attribute too
460
462
  end
461
463
 
462
464
  def respond_to?(method, *args, &block)
@@ -0,0 +1,55 @@
1
+ include Glimmer
2
+
3
+ shell {
4
+ text "User Profile"
5
+
6
+ composite {
7
+ grid_layout 2, false
8
+
9
+ group {
10
+ text "Name"
11
+ grid_layout 2, false
12
+ layout_data :fill, :fill, true, true
13
+ label {text "First"}; text {text "Bullet"}
14
+ label {text "Last"}; text {text "Tooth"}
15
+ }
16
+
17
+ group {
18
+ layout_data :fill, :fill, true, true
19
+ text "Gender"
20
+ radio {text "Male"; selection true}
21
+ radio {text "Female"}
22
+ }
23
+
24
+ group {
25
+ layout_data :fill, :fill, true, true
26
+ text "Role"
27
+ check {text "Student"; selection true}
28
+ check {text "Employee"; selection true}
29
+ }
30
+
31
+ group {
32
+ text "Experience"
33
+ row_layout
34
+ layout_data :fill, :fill, true, true
35
+ spinner {selection 5}; label {text "years"}
36
+ }
37
+
38
+ button {
39
+ text "save"
40
+ layout_data :right, :center, true, true
41
+ on_widget_selected {
42
+ message_box {
43
+ text 'Profile Saved!'
44
+ message 'User profile has been saved!'
45
+ }.open
46
+ }
47
+ }
48
+
49
+ button {
50
+ text "close"
51
+ layout_data :left, :center, true, true
52
+ on_widget_selected { exit(0) }
53
+ }
54
+ }
55
+ }.open
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.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-07 00:00:00.000000000 Z
11
+ date: 2020-09-14 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.3
18
+ version: 0.10.4
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.3
26
+ version: 0.10.4
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.10.0
60
+ version: 0.10.1
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.10.0
68
+ version: 0.10.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
@@ -214,6 +214,26 @@ dependencies:
214
214
  - - "<"
215
215
  - !ruby/object:Gem::Version
216
216
  version: 2.0.0
217
+ - !ruby/object:Gem::Dependency
218
+ requirement: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: 0.7.0
223
+ - - "<"
224
+ - !ruby/object:Gem::Version
225
+ version: 2.0.0
226
+ name: tty-markdown
227
+ type: :runtime
228
+ prerelease: false
229
+ version_requirements: !ruby/object:Gem::Requirement
230
+ requirements:
231
+ - - ">="
232
+ - !ruby/object:Gem::Version
233
+ version: 0.7.0
234
+ - - "<"
235
+ - !ruby/object:Gem::Version
236
+ version: 2.0.0
217
237
  - !ruby/object:Gem::Dependency
218
238
  requirement: !ruby/object:Gem::Requirement
219
239
  requirements:
@@ -304,7 +324,7 @@ dependencies:
304
324
  - - "~>"
305
325
  - !ruby/object:Gem::Version
306
326
  version: 0.7.0
307
- description: Glimmer DSL for SWT (Desktop GUI) - JRuby on SWT
327
+ description: Glimmer DSL for SWT (JRuby Desktop GUI)
308
328
  email: andy.am@gmail.com
309
329
  executables:
310
330
  - glimmer
@@ -406,6 +426,7 @@ files:
406
426
  - samples/elaborate/tic_tac_toe.rb
407
427
  - samples/elaborate/tic_tac_toe/board.rb
408
428
  - samples/elaborate/tic_tac_toe/cell.rb
429
+ - samples/elaborate/user_profile.rb
409
430
  - samples/hello/hello_browser.rb
410
431
  - samples/hello/hello_combo.rb
411
432
  - samples/hello/hello_computed.rb