glimmer-dsl-swt 0.4.1 → 0.5.4

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: d5cda7a8bb248622a5f6ce1347622064f56c2f9ce64d788c94b3ae7e9d4a633b
4
- data.tar.gz: 324e1458a7bfc6f6f10e92ac61080e5d046e2c6466ec89e42ebe12ece76b77e4
3
+ metadata.gz: 87bcff5d2b652ab8238bfa4860c5c7710e56155712aafc80dd3f8a4acd6a080c
4
+ data.tar.gz: 7b4dd240b1af86fa39233dec7b9e1e514245ec35513a1589510d0ab21ffbdf9b
5
5
  SHA512:
6
- metadata.gz: 7bd2e99cac06446f683102ae9825fbcda7c0ede916b842480688b2a76e5b1ceb9863bf006c683217a432b65a87accc86bba2b7521b7b1daa8b7d429bd12b5108
7
- data.tar.gz: 84d7055deee13d4b2c955edb555202ba882fdb961ed2b49759b27588777bca90000fceb51607a8cfbe2b5a023c4741012e98f8f1e9693318943985b79dbe751a
6
+ metadata.gz: 302644cbe7cbfc6c416585ab4c8d6cc38447ea0a3cb98eaf34473d8b0760f03d67eb9f59616ccf6d4e77b7cfc6112432dcdf6d16a5ccb310d90002ab2e39496d
7
+ data.tar.gz: efac7d222037f8e3434750c514b6afedcef6faefc60911291261387a4f0639ba73fb7d5f152abebfbc0ba6097701c124b83ca0975a0244add554cb58ab720a80
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
- # <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 /> Glimmer DSL for SWT 0.4.1 (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.5.4 (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
+ [![Maintainability](https://api.codeclimate.com/v1/badges/aaf1cba142dd351f84bd/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-swt/maintainability)
5
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)
6
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).
@@ -66,5 +67,11 @@ These features have been suggested. You might see them in a future version of Gl
66
67
 
67
68
  ## License
68
69
 
69
- Copyright (c) 2020 Andy Maleh.
70
- See LICENSE.txt for further details.
70
+ [MIT](https://opensource.org/licenses/MIT)
71
+
72
+ Copyright (c) 2020 - Andy Maleh.
73
+ See [LICENSE.txt](LICENSE.txt) for further details.
74
+
75
+ --
76
+
77
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built for [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development GUI Library).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.4
@@ -21,6 +21,94 @@ module Glimmer
21
21
  @@import_swt_packages = DEFAULT_IMPORT_SWT_PACKAGES if !defined?(@@import_swt_packages) || (defined?(@@import_swt_packages) && @@import_swt_packages == true)
22
22
  @@import_swt_packages
23
23
  end
24
+
25
+ # Returns Logging Devices. Default is [:stdout, :syslog]
26
+ def logging_devices
27
+ unless defined? @@logging_devices
28
+ @@logging_devices = [:stdout, :syslog]
29
+ end
30
+ @@logging_devices
31
+ end
32
+
33
+ # Logging Devices is an array of these possible values: :stdout (default), :stderr, :file, :syslog (default), :stringio
34
+ def logging_devices=(devices)
35
+ @@logging_devices = devices
36
+ reset_logger!
37
+ end
38
+
39
+ def logging_device_file_options
40
+ @@logging_device_file_options = {size: 1_000_000, age: 'daily', roll_by: 'number'} unless defined? @@logging_device_file_options
41
+ @@logging_device_file_options
42
+ end
43
+
44
+ def logging_device_file_options=(custom_options)
45
+ @@logging_device_file_options = custom_options
46
+ reset_logger!
47
+ end
48
+
49
+ def logging_appender_options
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
+ @@logging_appender_options
52
+ end
53
+
54
+ def logging_appender_options=(custom_options)
55
+ @@logging_appender_options = custom_options
56
+ reset_logger!
57
+ end
58
+
59
+ def logging_layout
60
+ unless defined? @@logging_layout
61
+ @@logging_layout = Logging.layouts.pattern(
62
+ pattern: '[%d] %-5l %c: %m\n',
63
+ date_pattern: '%Y-%m-%d %H:%M:%S'
64
+ )
65
+ end
66
+ @@logging_layout
67
+ end
68
+
69
+ def logging_layout=(custom_layout)
70
+ @@logging_layout = custom_layout
71
+ reset_logger!
72
+ end
73
+
74
+ def reset_logger!
75
+ @first_time = !defined?(@@logger)
76
+ old_level = logger.level unless @first_time
77
+ self.logger = Logging.logger['glimmer'].tap do |logger|
78
+ logger.level = old_level || :error
79
+ appenders = []
80
+ appenders << Logging.appenders.stdout(logging_appender_options) if logging_devices.include?(:stdout)
81
+ appenders << Logging.appenders.stderr(logging_appender_options) if logging_devices.include?(:stderr)
82
+ if logging_devices.include?(:file)
83
+ require 'fileutils'
84
+ FileUtils.mkdir_p('log')
85
+ appenders << Logging.appenders.rolling_file('log/glimmer.log', logging_appender_options.merge(logging_device_file_options)) if logging_devices.include?(:file)
86
+ end
87
+ if Object.const_defined?(:Syslog) && logging_devices.include?(:syslog)
88
+ Syslog.close if Syslog.opened?
89
+ appenders << Logging.appenders.syslog('glimmer', logging_appender_options)
90
+ end
91
+ logger.appenders = appenders
92
+ end
93
+ end
24
94
  end
25
95
  end
26
96
  end
97
+
98
+ Glimmer::Config.reset_logger!
99
+ if ENV['GLIMMER_LOGGER_LEVEL']
100
+ # if glimmer log level is being overridden for debugging purposes, then disable async logging making logging immediate
101
+ Glimmer::Config.logging_appender_options = Glimmer::Config.logging_appender_options.merge(async: false, auto_flushing: 1)
102
+ Glimmer::Config.logging_devices = [:stdout]
103
+ Glimmer::Config.logger.level = ENV['GLIMMER_LOGGER_LEVEL']
104
+ end
105
+ Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
106
+ method = method_symbol.to_s
107
+ result = false
108
+ result ||= method.start_with?('on_swt_') && is_a?(Glimmer::UI::CustomWidget) && respond_to?(method)
109
+ result ||= method == 'dispose' && is_a?(Glimmer::UI::CustomWidget) && respond_to?(method)
110
+ result ||= ['drag_source_proxy', 'drop_target_proxy'].include?(method) && is_a?(Glimmer::UI::CustomWidget)
111
+ result ||= method == 'post_initialize_child'
112
+ result ||= method.end_with?('=')
113
+ result ||= ['finish_edit!', 'search', 'all_tree_items', 'depth_first_search'].include?(method) && is_a?(Glimmer::UI::CustomWidget) && body_root.respond_to?(method)
114
+ end
@@ -6,9 +6,10 @@ if ENV['BUNDLER_REQUIRE'].to_s.downcase == 'true'
6
6
  require 'bundler'
7
7
  Bundler.require
8
8
  else
9
+ require 'glimmer'
10
+ require 'logging'
9
11
  require 'nested_inherited_jruby_include_package'
10
12
  require 'super_module'
11
- require 'glimmer'
12
13
  end
13
14
 
14
15
  # Internal requires
@@ -23,16 +23,18 @@ module Glimmer
23
23
  @table.body_root.column_properties = @column_properties
24
24
  end
25
25
  call(@model_binding.evaluate_property)
26
- observe(model_binding)
26
+ @table_observer_registration = observe(model_binding)
27
27
  @table.on_widget_disposed do |dispose_event|
28
28
  unregister_all_observables
29
29
  end
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
34
  if new_model_collection and new_model_collection.is_a?(Array)
35
- observe(new_model_collection, @column_properties)
35
+ @table_items_observer_registration&.unobserve
36
+ @table_items_observer_registration = observe(new_model_collection, @column_properties)
37
+ add_dependent(@table_observer_registration => @table_items_observer_registration)
36
38
  @model_collection = new_model_collection
37
39
  end
38
40
  populate_table(@model_collection, @table, @column_properties)
@@ -41,6 +43,7 @@ module Glimmer
41
43
  def populate_table(model_collection, parent, column_properties)
42
44
  selected_table_item_models = parent.swt_widget.getSelection.map(&:getData)
43
45
  parent.finish_edit!
46
+ parent.swt_widget.items.each(&:dispose)
44
47
  parent.swt_widget.removeAll
45
48
  model_collection.each do |model|
46
49
  table_item = TableItem.new(parent.swt_widget, SWT::SWTProxy[:none])
@@ -52,6 +55,7 @@ module Glimmer
52
55
  selected_table_items = parent.search {|item| selected_table_item_models.include?(item.getData) }
53
56
  selected_table_items = [parent.swt_widget.getItems.first].to_java(TableItem) if selected_table_items.empty? && !parent.swt_widget.getItems.empty?
54
57
  parent.swt_widget.setSelection(selected_table_items) unless selected_table_items.empty?
58
+ parent.sort
55
59
  end
56
60
  end
57
61
  end
@@ -41,10 +41,9 @@ module Glimmer
41
41
  old_tree_items = parent.all_tree_items
42
42
  old_tree_item_expansion_by_data = old_tree_items.reduce({}) {|hash, ti| hash.merge(ti.getData => ti.getExpanded)}
43
43
  old_tree_items.each do |tree_item|
44
- tree_item.getData('observer_registrations').each do |key, observer_registration|
45
- observer_registration.unregister
46
- end
44
+ tree_item.getData('observer_registrations').each(&:unregister)
47
45
  end
46
+ parent.swt_widget.items.each(&:dispose)
48
47
  parent.swt_widget.removeAll
49
48
  populate_tree_node(model_tree_root_node, parent.swt_widget, tree_properties)
50
49
  parent.all_tree_items.each { |ti| ti.setExpanded(!!old_tree_item_expansion_by_data[ti.getData]) }
@@ -54,10 +53,9 @@ module Glimmer
54
53
 
55
54
  def populate_tree_node(model_tree_node, parent, tree_properties)
56
55
  return if model_tree_node.nil?
57
- # TODO anticipate default tree properties if none were passed (like literal values text and children)
58
56
  tree_item = TreeItem.new(parent, SWT::SWTProxy[:none])
59
- observer_registrations = @tree_properties.reduce({}) do |hash, key_value_pair|
60
- hash.merge(key_value_pair.first => observe(model_tree_node, key_value_pair.last))
57
+ observer_registrations = @tree_properties.reduce([]) do |array, key_value_pair|
58
+ array + [observe(model_tree_node, key_value_pair.last)]
61
59
  end
62
60
  tree_item.setData('observer_registrations', observer_registrations)
63
61
  tree_item.setData(model_tree_node)
@@ -1,3 +1,4 @@
1
+
1
2
  require 'glimmer'
2
3
  require 'glimmer/dsl/expression'
3
4
  require 'glimmer/dsl/parent_expression'
@@ -18,7 +18,7 @@ module Glimmer
18
18
  if parent.swt_widget.is_a?(TabFolder)
19
19
  return true
20
20
  else
21
- Glimmer::Config.logger&.error "tab_item widget may only be used directly under a tab_folder widget!"
21
+ Glimmer::Config.logger.error {"tab_item widget may only be used directly under a tab_folder widget!"}
22
22
  end
23
23
  end
24
24
  false
@@ -8,17 +8,17 @@ module Glimmer
8
8
  include_package 'org.eclipse.swt.widgets'
9
9
 
10
10
  def can_interpret?(parent, keyword, *args, &block)
11
- Glimmer::Config.logger&.debug "keyword starts with on_: #{keyword.start_with?('on_')}"
11
+ Glimmer::Config.logger.debug {"keyword starts with on_: #{keyword.start_with?('on_')}"}
12
12
  return false unless keyword.start_with?('on_')
13
13
  widget_or_display_parentage = parent.respond_to?(:swt_widget) || parent.is_a?(Glimmer::SWT::DisplayProxy)
14
- Glimmer::Config.logger&.debug "parent is a widget or display: #{widget_or_display_parentage}"
14
+ Glimmer::Config.logger.debug {"parent #{parent} is a widget or display: #{widget_or_display_parentage}"}
15
15
  return false unless widget_or_display_parentage
16
- Glimmer::Config.logger&.debug "block exists?: #{!block.nil?}"
16
+ Glimmer::Config.logger.debug {"block exists?: #{!block.nil?}"}
17
17
  raise Glimmer::Error, "Listener is missing block for keyword: #{keyword}" unless block_given?
18
- Glimmer::Config.logger&.debug "args are empty?: #{args.empty?}"
18
+ Glimmer::Config.logger.debug {"args are empty?: #{args.empty?}"}
19
19
  raise Glimmer::Error, "Invalid listener arguments for keyword: #{keyword}(#{args})" unless args.empty?
20
20
  result = parent.can_handle_observation_request?(keyword)
21
- Glimmer::Config.logger&.debug "can add listener? #{result}"
21
+ Glimmer::Config.logger.debug {"can add listener? #{result}"}
22
22
  raise Glimmer::Error, "Invalid listener keyword: #{keyword}" unless result
23
23
  true
24
24
  end
@@ -17,7 +17,7 @@ module Glimmer
17
17
  project_name = File.basename(File.expand_path('.'))
18
18
  if !File.exists?('config/warble.rb')
19
19
  puts 'Generating JAR configuration (config/warble.rb) to use with Warbler...'
20
- system('mkdir -p config')
20
+ FileUtils.mkdir_p('config')
21
21
  system('warble config')
22
22
  new_config = File.read('config/warble.rb').split("\n").inject('') do |output, line|
23
23
  if line.include?('config.dirs =')
@@ -36,7 +36,7 @@ module Glimmer
36
36
  end
37
37
 
38
38
  def jar
39
- system('mkdir -p dist')
39
+ FileUtils.mkdir_p('dist')
40
40
  puts "Generating JAR with Warbler..."
41
41
  system('warble')
42
42
  end
@@ -49,11 +49,13 @@ module Glimmer
49
49
  version = (File.read(version_file).strip if File.exists?(version_file) && File.file?(version_file)) rescue nil
50
50
  license_file = File.expand_path('./LICENSE.txt')
51
51
  license = (File.read(license_file).strip if File.exists?(license_file) && File.file?(license_file)) rescue nil
52
+ copyright = license.split("\n").first
52
53
  human_name = project_name.underscore.titlecase
53
- command = "javapackager -deploy -native -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\" "
54
+ command = "javapackager -deploy -native -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?} "
54
55
  command += " -BjvmOptions=-XstartOnFirstThread " if OS.mac?
55
56
  command += " -BappVersion=#{version} -Bmac.CFBundleVersion=#{version} " if version
56
57
  command += " -srcfiles LICENSE.txt -BlicenseFile=LICENSE.txt " if license
58
+ command += " -Bcopyright=\"#{copyright}\" " if copyright
57
59
  command += " #{javapackager_extra_args} " if javapackager_extra_args
58
60
  command += " #{ENV['JAVAPACKAGER_EXTRA_ARGS']} " if ENV['JAVAPACKAGER_EXTRA_ARGS']
59
61
  puts "Generating DMG/PKG/APP/JNLP with javapackager..."
@@ -33,57 +33,97 @@ namespace :glimmer do
33
33
  end
34
34
 
35
35
 
36
- desc 'Scaffold a Glimmer application directory structure to begin building a new app'
36
+ desc 'Scaffold Glimmer application directory structure to build a new app'
37
37
  task :scaffold, [:app_name] do |t, args|
38
38
  require_relative 'scaffold'
39
39
  Scaffold.app(args[:app_name])
40
40
  end
41
41
 
42
42
  namespace :scaffold do
43
- desc 'Scaffold a Glimmer::UI::CustomShell subclass (represents a full window view) under app/views (namespace is optional)'
44
- task :custom_shell, [:custom_shell_name, :namespace] do |t, args|
43
+ desc 'Scaffold Glimmer::UI::CustomShell subclass (full window view) under app/views (namespace is optional) [alt: scaffold:cs]'
44
+ task :customshell, [:name, :namespace] do |t, args|
45
45
  require_relative 'scaffold'
46
- Scaffold.custom_shell(args[:custom_shell_name], args[:namespace])
46
+ Scaffold.custom_shell(args[:name], args[:namespace])
47
47
  end
48
48
 
49
- desc 'Scaffold a Glimmer::UI::CustomWidget subclass (represents a part of a view) under app/views (namespace is optional)'
50
- task :custom_widget, [:custom_widget_name, :namespace] do |t, args|
51
- require_relative 'scaffold'
52
- Scaffold.custom_widget(args[:custom_widget_name], args[:namespace])
53
- end
49
+ task :cs, [:name, :namespace] => :customshell
50
+ task :custom_shell, [:name, :namespace] => :customshell
51
+ task :"custom-shell", [:name, :namespace] => :customshell
54
52
 
55
- desc 'Scaffold a Glimmer::UI::CustomShell subclass (represents a full window view) under its own Ruby gem + app project (namespace is required)'
56
- task :custom_shell_gem, [:custom_shell_name, :namespace] do |t, args|
53
+ desc 'Scaffold Glimmer::UI::CustomWidget subclass (part of a view) under app/views (namespace is optional) [alt: scaffold:cw]'
54
+ task :customwidget, [:name, :namespace] do |t, args|
57
55
  require_relative 'scaffold'
58
- Scaffold.custom_shell_gem(args[:custom_shell_name], args[:namespace])
56
+ Scaffold.custom_widget(args[:name], args[:namespace])
59
57
  end
60
58
 
61
- desc 'Scaffold a Glimmer::UI::CustomWidget subclass (represents a part of a view) under its own Ruby gem project (namespace is required)'
62
- task :custom_widget_gem, [:custom_widget_name, :namespace] do |t, args|
63
- require_relative 'scaffold'
64
- Scaffold.custom_widget_gem(args[:custom_widget_name], args[:namespace])
59
+ task :cw, [:name, :namespace] => :customwidget
60
+ task :custom_widget, [:name, :namespace] => :customwidget
61
+ task :"custom-widget", [:name, :namespace] => :customwidget
62
+
63
+ namespace :gem do
64
+ desc 'Scaffold Glimmer::UI::CustomShell subclass (full window view) under its own Ruby gem + app project (namespace is required) [alt: scaffold:gem:cs]'
65
+ task :customshell, [:name, :namespace] do |t, args|
66
+ require_relative 'scaffold'
67
+ Scaffold.custom_shell_gem(args[:name], args[:namespace])
68
+ end
69
+
70
+ task :cs, [:name, :namespace] => :customshell
71
+ task :custom_shell, [:name, :namespace] => :customshell
72
+ task :"custom-shell", [:name, :namespace] => :customshell
73
+
74
+ desc 'Scaffold Glimmer::UI::CustomWidget subclass (part of a view) under its own Ruby gem project (namespace is required) [alt: scaffold:gem:cw]'
75
+ task :customwidget, [:name, :namespace] do |t, args|
76
+ require_relative 'scaffold'
77
+ Scaffold.custom_widget_gem(args[:name], args[:namespace])
78
+ end
79
+
80
+ task :cw, [:name, :namespace] => :customwidget
81
+ task :custom_widget, [:name, :namespace] => :customwidget
82
+ task :"custom-widget", [:name, :namespace] => :customwidget
65
83
  end
84
+
85
+ # legacy support
86
+
87
+ task :custom_shell_gem, [:name, :namespace] => 'gem:customshell'
88
+ task :custom_widget_gem, [:name, :namespace] => 'gem:customwidget'
89
+
66
90
  end
67
91
 
68
92
  namespace :list do
69
93
  task :list_require do
70
94
  require_relative 'rake_task/list'
71
95
  end
72
-
73
- desc 'List Glimmer custom widget gems available at rubygems.org (query is optional)'
74
- task :custom_widget_gems, [:query] => :list_require do |t, args|
75
- Glimmer::RakeTask::List.custom_widget_gems(args[:query])
76
- end
77
96
 
78
- desc 'List Glimmer custom shell gems available at rubygems.org (query is optional)'
79
- task :custom_shell_gems, [:query] => :list_require do |t, args|
80
- Glimmer::RakeTask::List.custom_shell_gems(args[:query])
81
- end
97
+ namespace :gems do
98
+ desc 'List Glimmer custom widget gems available at rubygems.org (query is optional) [alt: list:gems:cw]'
99
+ task :customwidget, [:query] => :list_require do |t, args|
100
+ Glimmer::RakeTask::List.custom_widget_gems(args[:query])
101
+ end
102
+
103
+ task :cw, [:query] => :customwidget
104
+ task :custom_widget, [:query] => :customwidget
105
+ task :"custom-widget", [:query] => :customwidget
106
+
107
+ desc 'List Glimmer custom shell gems available at rubygems.org (query is optional) [alt: list:gems:cs]'
108
+ task :customshell, [:query] => :list_require do |t, args|
109
+ Glimmer::RakeTask::List.custom_shell_gems(args[:query])
110
+ end
111
+
112
+ task :cs, [:query] => :customshell
113
+ task :custom_shell, [:query] => :customshell
114
+ task :"custom-shell", [:query] => :customshell
115
+
116
+ desc 'List Glimmer DSL gems available at rubygems.org (query is optional)'
117
+ task :dsl, [:query] => :list_require do |t, args|
118
+ Glimmer::RakeTask::List.dsl_gems(args[:query])
119
+ end
82
120
 
83
- desc 'List Glimmer DSL gems available at rubygems.org (query is optional)'
84
- task :dsl_gems, [:query] => :list_require do |t, args|
85
- Glimmer::RakeTask::List.dsl_gems(args[:query])
86
121
  end
87
122
 
123
+ # legacy support
124
+
125
+ task :custom_shell_gems, [:name, :namespace] => 'gems:customshell'
126
+ task :custom_widget_gems, [:name, :namespace] => 'gems:customwidget'
127
+
88
128
  end
89
129
  end
@@ -52,7 +52,7 @@ module Glimmer
52
52
  def method_missing(method, *args, &block)
53
53
  swt_color.send(method, *args, &block)
54
54
  rescue => e
55
- Glimmer::Config.logger&.debug "Neither ColorProxy nor #{swt_color.class.name} can handle the method ##{method}"
55
+ Glimmer::Config.logger.debug {"Neither ColorProxy nor #{swt_color.class.name} can handle the method ##{method}"}
56
56
  super
57
57
  end
58
58
 
@@ -39,7 +39,7 @@ module Glimmer
39
39
  def method_missing(method, *args, &block)
40
40
  swt_display.send(method, *args, &block)
41
41
  rescue => e
42
- Glimmer::Config.logger&.debug "Neither DisplayProxy nor #{swt_display.class.name} can handle the method ##{method}"
42
+ Glimmer::Config.logger.debug {"Neither DisplayProxy nor #{swt_display.class.name} can handle the method ##{method}"}
43
43
  super
44
44
  end
45
45
 
@@ -31,7 +31,7 @@ module Glimmer
31
31
  begin
32
32
  @swt_layout_data = swt_layout_data_class.new(*args)
33
33
  rescue => e
34
- Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
34
+ Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
35
35
  @swt_layout_data = args.first if args.count == 1
36
36
  end
37
37
  @widget_proxy.swt_widget.setLayoutData(@swt_layout_data)
@@ -34,8 +34,8 @@ module Glimmer
34
34
  end
35
35
  swt_layout_class
36
36
  rescue => e
37
- Glimmer::Config.logger&.debug e.message
38
- # Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
37
+ Glimmer::Config.logger.debug {e.message}
38
+ # Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
39
39
  raise e
40
40
  end
41
41
  end
@@ -15,11 +15,13 @@ module Glimmer
15
15
 
16
16
  def initialize(parent, style)
17
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?
18
19
  @swt_widget = MessageBox.new(parent, style)
19
20
  end
20
21
 
21
22
  def open
22
23
  @swt_widget.open
24
+ @temporary_parent&.dispose
23
25
  end
24
26
 
25
27
  # TODO refactor the following methods to put in a JavaBean mixin or somethin (perhaps contribute to OSS project too)
@@ -84,10 +84,6 @@ module Glimmer
84
84
  @swt_widget.setVisible(false)
85
85
  end
86
86
 
87
- def close
88
- @swt_widget.close
89
- end
90
-
91
87
  def visible?
92
88
  @swt_widget.isDisposed ? false : @swt_widget.isVisible
93
89
  end
@@ -134,7 +130,7 @@ module Glimmer
134
130
  begin
135
131
  @display.sleep unless @display.readAndDispatch
136
132
  rescue => e
137
- Glimmer::Config.logger&.debug e.full_message
133
+ Glimmer::Config.logger.debug {e.full_message}
138
134
  end
139
135
  end
140
136
  end
@@ -61,12 +61,12 @@ module Glimmer
61
61
  negative ? ~bit_value : bit_value
62
62
  rescue => e
63
63
  begin
64
- # Glimmer::Config.logger&.debug(e.full_message)
64
+ # Glimmer::Config.logger.debug {e.full_message}
65
65
  alternative_swt_constant_symbol = constant_source_class.constants.find {|c| c.to_s.upcase == swt_constant_symbol.to_s.upcase}
66
66
  bit_value = constant_source_class.const_get(alternative_swt_constant_symbol)
67
67
  negative ? ~bit_value : bit_value
68
68
  rescue => e
69
- # Glimmer::Config.logger&.debug(e.full_message)
69
+ # Glimmer::Config.logger.debug {e.full_message}
70
70
  bit_value = extra_styles[swt_constant_symbol]
71
71
  if bit_value
72
72
  negative ? ~bit_value : bit_value
@@ -61,6 +61,7 @@ module Glimmer
61
61
  combo: {
62
62
  widget_value_property: :text,
63
63
  editor_gui: lambda do |args, model, property, table_proxy|
64
+ first_time = true
64
65
  table_proxy.table_editor.minimumHeight = 25
65
66
  table_editor_widget_proxy = combo(*args) {
66
67
  items model.send("#{property}_options")
@@ -77,7 +78,9 @@ module Glimmer
77
78
  end
78
79
  }
79
80
  on_widget_selected {
80
- table_proxy.finish_edit!
81
+ if !OS.windows? || !first_time || first_time && model.send(property) != table_editor_widget_proxy.swt_widget.text
82
+ table_proxy.finish_edit!
83
+ end
81
84
  }
82
85
  }
83
86
  table_editor_widget_proxy
@@ -297,7 +300,7 @@ module Glimmer
297
300
  }
298
301
  @table_editor.setEditor(@table_editor_widget_proxy.swt_widget, table_item, column_index)
299
302
  rescue => e
300
- Glimmer::Config.logger&.error e.full_message
303
+ Glimmer::Config.logger.error {e.full_message}
301
304
  raise e
302
305
  end
303
306
 
@@ -3,7 +3,6 @@ require 'glimmer/swt/color_proxy'
3
3
  require 'glimmer/swt/font_proxy'
4
4
  require 'glimmer/swt/swt_proxy'
5
5
  require 'glimmer/swt/dnd_proxy'
6
- require 'glimmer/data_binding/observable_widget'
7
6
 
8
7
  # TODO refactor to make file smaller and extract sub-widget-proxies out of this
9
8
 
@@ -20,11 +19,10 @@ module Glimmer
20
19
  # Follows the Proxy Design Pattern
21
20
  class WidgetProxy
22
21
  include Packages
23
- include DataBinding::ObservableWidget
24
22
 
25
23
  DEFAULT_STYLES = {
26
24
  "text" => [:border],
27
- "table" => [:border],
25
+ "table" => [:virtual, :border, :full_selection],
28
26
  "tree" => [:virtual, :border, :h_scroll, :v_scroll],
29
27
  "spinner" => [:border],
30
28
  "styled_text" => [:border],
@@ -268,17 +266,17 @@ module Glimmer
268
266
  swt_widget_name = underscored_widget_name.camelcase(:upper)
269
267
  swt_widget_class = eval(swt_widget_name)
270
268
  unless swt_widget_class.ancestors.include?(org.eclipse.swt.widgets.Widget)
271
- Glimmer::Config.logger&.debug("Class #{swt_widget_class} matching #{underscored_widget_name} is not a subclass of org.eclipse.swt.widgets.Widget")
269
+ Glimmer::Config.logger.debug {"Class #{swt_widget_class} matching #{underscored_widget_name} is not a subclass of org.eclipse.swt.widgets.Widget"}
272
270
  return nil
273
271
  end
274
272
  swt_widget_class
275
273
  rescue SyntaxError, NameError => e
276
- Glimmer::Config.logger&.debug e.full_message
277
- # Glimmer::Config.logger&.debug("#{e.message}\n#{e.backtrace.join("\n")}")
274
+ Glimmer::Config.logger.debug {e.full_message}
275
+ # Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
278
276
  nil
279
277
  rescue => e
280
- Glimmer::Config.logger&.debug e.full_message
281
- # Glimmer::Config.logger&.debug("#{e.message}\n#{e.backtrace.join("\n")}")
278
+ Glimmer::Config.logger.debug {e.full_message}
279
+ # Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
282
280
  nil
283
281
  end
284
282
 
@@ -337,7 +335,7 @@ module Glimmer
337
335
 
338
336
  # TODO eliminate duplication in the following methods perhaps by relying on exceptions
339
337
 
340
- def can_handle_observation_request?(observation_request)
338
+ def can_handle_observation_request?(observation_request)
341
339
  observation_request = observation_request.to_s
342
340
  if observation_request.start_with?('on_swt_')
343
341
  constant_name = observation_request.sub(/^on_swt_/, '')
@@ -359,7 +357,7 @@ module Glimmer
359
357
  end
360
358
  end
361
359
  rescue => e
362
- Glimmer::Config.logger&.debug(e.full_message)
360
+ Glimmer::Config.logger.debug {e.full_message}
363
361
  false
364
362
  end
365
363
 
@@ -376,6 +374,7 @@ module Glimmer
376
374
  end
377
375
 
378
376
  def handle_observation_request(observation_request, &block)
377
+ observation_request = observation_request.to_s
379
378
  if observation_request.start_with?('on_swt_')
380
379
  constant_name = observation_request.sub(/^on_swt_/, '')
381
380
  add_swt_event_listener(constant_name, &block)
@@ -397,14 +396,20 @@ module Glimmer
397
396
  end
398
397
 
399
398
  def method_missing(method, *args, &block)
400
- swt_widget.send(method, *args, &block)
399
+ if can_handle_observation_request?(method)
400
+ handle_observation_request(method, &block)
401
+ else
402
+ swt_widget.send(method, *args, &block)
403
+ end
401
404
  rescue => e
402
- Glimmer::Config.logger&.debug "Neither WidgetProxy nor #{swt_widget.class.name} can handle the method ##{method}"
405
+ Glimmer::Config.logger.debug {"Neither WidgetProxy nor #{swt_widget.class.name} can handle the method ##{method}"}
403
406
  super
404
407
  end
405
408
 
406
409
  def respond_to?(method, *args, &block)
407
- super || swt_widget.respond_to?(method, *args, &block)
410
+ super ||
411
+ can_handle_observation_request?(method) ||
412
+ swt_widget.respond_to?(method, *args, &block)
408
413
  end
409
414
 
410
415
  private
@@ -587,7 +592,7 @@ module Glimmer
587
592
  :background_image => lambda do |value|
588
593
  if value.is_a?(String)
589
594
  if value.start_with?('uri:classloader')
590
- value = value.sub(/^uri\:classloader\:\//, '')
595
+ value = value.sub(/^uri\:classloader\:/, '')
591
596
  object = java.lang.Object.new
592
597
  value = object.java_class.resource_as_stream(value)
593
598
  value = java.io.BufferedInputStream.new(value)
@@ -613,6 +618,36 @@ module Glimmer
613
618
  value
614
619
  end
615
620
  end,
621
+ :image => lambda do |value|
622
+ if value.is_a?(String)
623
+ if value.start_with?('uri:classloader')
624
+ value = value.sub(/^uri\:classloader\:/, '')
625
+ object = java.lang.Object.new
626
+ value = object.java_class.resource_as_stream(value)
627
+ value = java.io.BufferedInputStream.new(value)
628
+ end
629
+ image_data = ImageData.new(value)
630
+ Image.new(@swt_widget.getDisplay, image_data)
631
+ else
632
+ value
633
+ end
634
+ end,
635
+ :images => lambda do |array|
636
+ array.to_a.map do |value|
637
+ if value.is_a?(String)
638
+ if value.start_with?('uri:classloader')
639
+ value = value.sub(/^uri\:classloader\:/, '')
640
+ object = java.lang.Object.new
641
+ value = object.java_class.resource_as_stream(value)
642
+ value = java.io.BufferedInputStream.new(value)
643
+ end
644
+ image_data = ImageData.new(value)
645
+ Image.new(@swt_widget.getDisplay, image_data)
646
+ else
647
+ value
648
+ end
649
+ end.to_java(Image)
650
+ end,
616
651
  :items => lambda do |value|
617
652
  value.to_java :string
618
653
  end,
@@ -5,7 +5,7 @@ module Glimmer
5
5
  module CustomShell
6
6
  include SuperModule
7
7
  include Glimmer::UI::CustomWidget
8
-
8
+
9
9
  def initialize(parent, *swt_constants, options, &content)
10
10
  super
11
11
  @swt_widget.set_data('custom_shell', self)
@@ -5,7 +5,6 @@ require 'glimmer/swt/display_proxy'
5
5
  require 'glimmer/util/proc_tracker'
6
6
  require 'glimmer/data_binding/observer'
7
7
  require 'glimmer/data_binding/observable_model'
8
- require 'glimmer/data_binding/observable_widget'
9
8
 
10
9
  module Glimmer
11
10
  module UI
@@ -15,7 +14,6 @@ module Glimmer
15
14
 
16
15
  super_module_included do |klass|
17
16
  klass.include(Glimmer) unless klass.name.include?('Glimmer::UI::CustomShell')
18
- klass.prepend DataBinding::ObservableWidget
19
17
  Glimmer::UI::CustomWidget.add_custom_widget_namespaces_for(klass) unless klass.name.include?('Glimmer::UI::CustomShell')
20
18
  end
21
19
 
@@ -36,15 +34,15 @@ module Glimmer
36
34
  return constant if constant.ancestors.include?(Glimmer::UI::CustomWidget)
37
35
  constant
38
36
  rescue => e
39
- # Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
37
+ # Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
40
38
  result
41
39
  end
42
40
  end
43
41
  end
44
42
  raise "#{underscored_custom_widget_name} has no custom widget class!"
45
43
  rescue => e
46
- Glimmer::Config.logger&.debug e.message
47
- Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
44
+ Glimmer::Config.logger.debug {e.message}
45
+ Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
48
46
  nil
49
47
  end
50
48
 
@@ -139,6 +137,11 @@ module Glimmer
139
137
  execute_hooks('after_body')
140
138
  end
141
139
 
140
+ # Subclasses may override to perform post initialization work on an added child
141
+ def post_initialize_child(child)
142
+ # No Op by default
143
+ end
144
+
142
145
  def can_handle_observation_request?(observation_request)
143
146
  observation_request = observation_request.to_s
144
147
  result = false
@@ -230,12 +233,17 @@ module Glimmer
230
233
  end
231
234
 
232
235
  def method_missing(method, *args, &block)
233
- body_root.send(method, *args, &block)
236
+ if can_handle_observation_request?(method)
237
+ handle_observation_request(method, &block)
238
+ else
239
+ body_root.send(method, *args, &block)
240
+ end
234
241
  end
235
242
 
236
243
  alias local_respond_to? respond_to?
237
244
  def respond_to?(method, *args, &block)
238
245
  super or
246
+ can_handle_observation_request?(method) or
239
247
  body_root.respond_to?(method, *args, &block)
240
248
  end
241
249
 
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.4.1
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-21 00:00:00.000000000 Z
11
+ date: 2020-07-29 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.9.5
18
+ version: 0.10.1
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.9.5
26
+ version: 0.10.1
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.8.2
60
+ version: 0.9.0
61
61
  name: puts_debuggerer
62
62
  type: :runtime
63
63
  prerelease: false
@@ -65,67 +65,67 @@ dependencies:
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.8.2
68
+ version: 0.9.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 1.2.4
74
+ version: 2.3.9
75
75
  - - "<"
76
76
  - !ruby/object:Gem::Version
77
- version: 2.0.0
78
- name: text-table
77
+ version: 3.0.0
78
+ name: jeweler
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 1.2.4
85
+ version: 2.3.9
86
86
  - - "<"
87
87
  - !ruby/object:Gem::Version
88
- version: 2.0.0
88
+ version: 3.0.0
89
89
  - !ruby/object:Gem::Dependency
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
- version: 1.0.0
94
+ version: 2.3.0
95
95
  - - "<"
96
96
  - !ruby/object:Gem::Version
97
- version: 2.0.0
98
- name: os
97
+ version: 3.0.0
98
+ name: logging
99
99
  type: :runtime
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - ">="
104
104
  - !ruby/object:Gem::Version
105
- version: 1.0.0
105
+ version: 2.3.0
106
106
  - - "<"
107
107
  - !ruby/object:Gem::Version
108
- version: 2.0.0
108
+ version: 3.0.0
109
109
  - !ruby/object:Gem::Dependency
110
110
  requirement: !ruby/object:Gem::Requirement
111
111
  requirements:
112
112
  - - ">="
113
113
  - !ruby/object:Gem::Version
114
- version: 2.0.5
114
+ version: 1.0.0
115
115
  - - "<"
116
116
  - !ruby/object:Gem::Version
117
- version: 3.0.0
118
- name: warbler
117
+ version: 2.0.0
118
+ name: os
119
119
  type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - ">="
124
124
  - !ruby/object:Gem::Version
125
- version: 2.0.5
125
+ version: 1.0.0
126
126
  - - "<"
127
127
  - !ruby/object:Gem::Version
128
- version: 3.0.0
128
+ version: 2.0.0
129
129
  - !ruby/object:Gem::Dependency
130
130
  requirement: !ruby/object:Gem::Requirement
131
131
  requirements:
@@ -151,41 +151,61 @@ dependencies:
151
151
  requirements:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
- version: 2.3.9
154
+ version: 6.2.1
155
155
  - - "<"
156
156
  - !ruby/object:Gem::Version
157
- version: 3.0.0
158
- name: jeweler
157
+ version: 7.0.0
158
+ name: rdoc
159
159
  type: :runtime
160
160
  prerelease: false
161
161
  version_requirements: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
- version: 2.3.9
165
+ version: 6.2.1
166
166
  - - "<"
167
167
  - !ruby/object:Gem::Version
168
- version: 3.0.0
168
+ version: 7.0.0
169
169
  - !ruby/object:Gem::Dependency
170
170
  requirement: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - ">="
173
173
  - !ruby/object:Gem::Version
174
- version: 6.2.1
174
+ version: 1.2.4
175
175
  - - "<"
176
176
  - !ruby/object:Gem::Version
177
- version: 7.0.0
178
- name: rdoc
177
+ version: 2.0.0
178
+ name: text-table
179
179
  type: :runtime
180
180
  prerelease: false
181
181
  version_requirements: !ruby/object:Gem::Requirement
182
182
  requirements:
183
183
  - - ">="
184
184
  - !ruby/object:Gem::Version
185
- version: 6.2.1
185
+ version: 1.2.4
186
186
  - - "<"
187
187
  - !ruby/object:Gem::Version
188
- version: 7.0.0
188
+ version: 2.0.0
189
+ - !ruby/object:Gem::Dependency
190
+ requirement: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 2.0.5
195
+ - - "<"
196
+ - !ruby/object:Gem::Version
197
+ version: 3.0.0
198
+ name: warbler
199
+ type: :runtime
200
+ prerelease: false
201
+ version_requirements: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: 2.0.5
206
+ - - "<"
207
+ - !ruby/object:Gem::Version
208
+ version: 3.0.0
189
209
  - !ruby/object:Gem::Dependency
190
210
  requirement: !ruby/object:Gem::Requirement
191
211
  requirements: