glimmer-dsl-swt 0.6.8 → 0.6.9

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: 8f75e570d4a595c012b464d8dffa7149200385d8053dc39640d5be59d8f4980c
4
- data.tar.gz: 1fbd61272f851ffa8aa1f6dbcf0afa57e898147c3982f69a180018a2d5d0e6c3
3
+ metadata.gz: f8cb96b5eda19eb65af0d9fa5b8f79050a341f5f148e78c13a27b18c07cef083
4
+ data.tar.gz: 6e925dab92f1ea52557c2f9078a1c7b0b0068225644da25ce81677e6d4b9fca4
5
5
  SHA512:
6
- metadata.gz: 3c78fc793f87813acaf59b2732a362fc37da683c79b2610dc7d9d74c37ddd56ee1ac5d33209ee509d2cc1a3c62a0fb5db56b8275d88a93b6c4d7e8c5906511b0
7
- data.tar.gz: 90941e2906ecc6c87e6685f8c8ff62fda790a43c3af519761011cefa56466336e5705e8deb49e25eeef60020a7cf6ab65c19c7c3f1c1a0f325158053bcf778c4
6
+ metadata.gz: f23a464b36497e60e0379b90a1f17f630d84c0ff01359a89a9dd8cfe008306bbbd779c1b456c3ff17cdbaae331b795b1241597d57b653e063c3aa8af7f463ce7
7
+ data.tar.gz: 02a87c762461b89acac3385dfb2ab4ea0089e6b3b4320f60e843758e5b28df2036cb4524e8b0851b792576401857de3e77e9981bf92ee98205ddfadf425cbf8a
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.8 (JRuby 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.9 (JRuby 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.8
1
+ 0.6.9
@@ -20,7 +20,13 @@ module Glimmer
20
20
  end
21
21
 
22
22
  def interpret(parent, keyword, *args, &block)
23
- Glimmer::SWT::DisplayProxy.instance.swt_display.send(exec_operation, &block)
23
+ Glimmer::SWT::DisplayProxy.instance.swt_display.send(exec_operation) do |*args|
24
+ begin
25
+ block.call(*args)
26
+ rescue => e
27
+ Glimmer::Config.logger.error e.full_message
28
+ end
29
+ end
24
30
  end
25
31
  end
26
32
  end
@@ -19,14 +19,12 @@ namespace :glimmer do
19
19
  end
20
20
 
21
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$/, '')}
22
+ glimmer_cw_gems = Gem.find_latest_files('glimmer-cw-*')
23
+ glimmer_cs_gems = Gem.find_latest_files('glimmer-cs-*')
24
+ glimmer_dsl_gems = Gem.find_latest_files('glimmer-dsl-*')
25
+ glimmer_gem_lib_files = glimmer_cw_gems + glimmer_cs_gems + glimmer_dsl_gems
26
+ glimmer_gem_lib_files = glimmer_gem_lib_files.map {|file| file.sub(/\.rb$/, '')}.uniq.reject {|file| file.include?('glimmer-cs-gladiator')}
27
+ glimmer_gem_lib_files.each {|file| require file}
30
28
  end
31
29
 
32
30
  desc 'Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples.'
@@ -36,7 +36,8 @@ module Glimmer
36
36
  class << self
37
37
  def editors
38
38
  @editors ||= {
39
- text: {
39
+ # ensure editor can work with string keys not just symbols (leave one string in for testing)
40
+ 'text' => {
40
41
  widget_value_property: :text,
41
42
  editor_gui: lambda do |args, model, property, table_proxy|
42
43
  table_proxy.table_editor.minimumHeight = 20
@@ -303,6 +304,7 @@ module Glimmer
303
304
  end
304
305
 
305
306
  def edit_table_item(table_item, column_index, before_write: nil, after_write: nil, after_cancel: nil)
307
+ require 'facets/hash/symbolize_keys'
306
308
  return if table_item.nil?
307
309
  model = table_item.data
308
310
  property = column_properties[column_index]
@@ -314,10 +316,10 @@ module Glimmer
314
316
  editor_config = editor_config.to_a
315
317
  editor_widget_options = editor_config.last.is_a?(Hash) ? editor_config.last : {}
316
318
  editor_widget_arg_last_index = editor_config.last.is_a?(Hash) ? -2 : -1
317
- editor_widget = editor_config[0] || :text
319
+ editor_widget = (editor_config[0] || :text).to_sym
318
320
  editor_widget_args = editor_config[1..editor_widget_arg_last_index]
319
321
  model_editing_property = editor_widget_options[:property] || property
320
- widget_value_property = TableProxy::editors[editor_widget][:widget_value_property]
322
+ widget_value_property = TableProxy::editors.symbolize_keys[editor_widget][:widget_value_property]
321
323
 
322
324
  @cancel_edit = lambda do |event=nil|
323
325
  @cancel_in_progress = true
@@ -354,7 +356,7 @@ module Glimmer
354
356
  end
355
357
 
356
358
  content {
357
- @table_editor_widget_proxy = TableProxy::editors[editor_widget][:editor_gui].call(editor_widget_args, model, model_editing_property, self)
359
+ @table_editor_widget_proxy = TableProxy::editors.symbolize_keys[editor_widget][:editor_gui].call(editor_widget_args, model, model_editing_property, self)
358
360
  }
359
361
  @table_editor.setEditor(@table_editor_widget_proxy.swt_widget, table_item, column_index)
360
362
  rescue => e
@@ -74,8 +74,17 @@ module Glimmer
74
74
  }
75
75
 
76
76
  class << self
77
- def create(keyword, parent, args)
78
- widget_proxy_class(keyword).new(keyword, parent, args)
77
+ # Instantiates the right WidgetProxy subclass for passed in keyword
78
+ # Args are: keyword, parent, swt_widget_args (including styles)
79
+ def create(*init_args, swt_widget: nil)
80
+ return swt_widget.get_data('proxy') if swt_widget&.get_data('proxy')
81
+ keyword, parent, args = init_args
82
+ selected_widget_proxy_class = widget_proxy_class(keyword || underscored_widget_name(swt_widget))
83
+ if init_args.empty?
84
+ selected_widget_proxy_class.new(swt_widget: swt_widget)
85
+ else
86
+ selected_widget_proxy_class.new(*init_args)
87
+ end
79
88
  end
80
89
 
81
90
  def widget_proxy_class(keyword)
@@ -97,8 +106,13 @@ module Glimmer
97
106
 
98
107
  # Initializes a new SWT Widget
99
108
  #
109
+ # It is preferred to use `::create` method instead since it instantiates the
110
+ # right subclass per widget keyword
111
+ #
112
+ # keyword, parent, swt_widget_args (including styles)
113
+ #
100
114
  # Styles is a comma separate list of symbols representing SWT styles in lower case
101
- def initialize(*init_args, swt_widget: nil)
115
+ def initialize(*init_args, swt_widget: nil)
102
116
  if swt_widget.nil?
103
117
  underscored_widget_name, parent, args = init_args
104
118
  @parent_proxy = parent
@@ -109,11 +123,14 @@ module Glimmer
109
123
  @swt_widget = swt_widget
110
124
  underscored_widget_name = self.class.underscored_widget_name(@swt_widget)
111
125
  parent_proxy_class = self.class.widget_proxy_class(self.class.underscored_widget_name(@swt_widget.parent))
112
- @parent_proxy = parent_proxy_class.new(swt_widget: swt_widget.parent)
126
+ parent = swt_widget.parent
127
+ @parent_proxy = parent.get_data('proxy') || parent_proxy_class.new(swt_widget: parent)
128
+ end
129
+ if @swt_widget&.get_data('proxy').nil?
130
+ @swt_widget.set_data('proxy', self)
131
+ DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@swt_widget)
132
+ @parent_proxy.post_initialize_child(self)
113
133
  end
114
- @swt_widget.set_data('proxy', self)
115
- DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@swt_widget)
116
- @parent_proxy.post_initialize_child(self)
117
134
  end
118
135
 
119
136
  # Subclasses may override to perform post initialization work on an added child
@@ -348,11 +365,7 @@ module Glimmer
348
365
  end
349
366
 
350
367
  def has_style?(style)
351
- begin
352
- comparison = SWTProxy[style]
353
- rescue
354
- comparison = DNDProxy[style]
355
- end
368
+ comparison = interpret_style(style)
356
369
  (@swt_widget.style & comparison) == comparison
357
370
  end
358
371
 
@@ -475,21 +488,17 @@ module Glimmer
475
488
  private
476
489
 
477
490
  def style(underscored_widget_name, styles)
478
- styles = [styles].flatten.compact
479
- if styles.empty?
480
- default_style(underscored_widget_name)
481
- else
482
- begin
483
- SWTProxy[*styles]
484
- rescue
485
- DNDProxy[*styles]
486
- end
487
- end
491
+ styles = [styles].flatten.compact
492
+ styles = default_style(underscored_widget_name) if styles.empty?
493
+ interpret_style(*styles)
494
+ end
495
+
496
+ def interpret_style(*styles)
497
+ SWTProxy[*styles] rescue DNDProxy[*styles]
488
498
  end
489
499
 
490
500
  def default_style(underscored_widget_name)
491
- styles = DEFAULT_STYLES[underscored_widget_name] || [:none]
492
- SWTProxy[styles] rescue DNDProxy[styles]
501
+ DEFAULT_STYLES[underscored_widget_name] || [:none]
493
502
  end
494
503
 
495
504
  def ruby_attribute_setter(attribute_name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.8
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh