glimmer-dsl-swt 0.1.1 → 0.2.2

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: 6b7dbe91f4446b09448aa58ad33e7192060feb314ad3cb6e146c95f6aef034c4
4
- data.tar.gz: 030a51954d8ed32fc128a729c7469e3c313e18615aa47caa588920dd9706c49e
3
+ metadata.gz: 564118c89658344e48e07e795447c78db4b4d61fd6e48c48ba0fae9e48e4cc2c
4
+ data.tar.gz: a36895cc1374171c078546a986cdbfb6b677d0547d20099c42d631be9d4865bd
5
5
  SHA512:
6
- metadata.gz: 3240f754fb9948de06ed1d84af8f037ca8a520aaf4d0b2d6958bf856a650ee53c13f49391e1be23566ff6f51b8792bb21e99f7bbc781c5c6c3b16b378f52193f
7
- data.tar.gz: 6e7f3a1fb5614ece07eb98dd0f44cdefe011e69b1bb686bd8ff5c8b9968a96b692a5bace1b648c16d4aa7d66ac5e716127097fe6f08c6e744adfa307f42dfc33
6
+ metadata.gz: 3f1edda00261bc1fa2f4d8459f08378b0924d440c6e0b7ebd42281c0d689a66870089da127f8ef45a18110808a201852d71481582f8712136151863cff848c88
7
+ data.tar.gz: 75742ed4193c5139a2a800787211342e19cee44bd0aa34abe794db8b8c37a2ccfc5300de35b31de95f5fa5826e23a8207db8d6bd097512eb0c1b256de4ffb277
data/README.md CHANGED
@@ -1,11 +1,36 @@
1
- # Glimmer DSL for SWT 0.1.1 (Desktop GUI)
1
+ # <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 /> Glimmer DSL for SWT 0.2.2 (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
+ [![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
+ [![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)
4
6
 
5
- [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for SWT enables desktop development with Glimmer.
7
+ [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [SWT](https://www.eclipse.org/swt/) enables desktop development with [Glimmer](https://github.com/AndyObtiva/glimmer).
6
8
 
7
- You may find full setup/usage instructions at the main Glimmer project page:
8
- [https://github.com/AndyObtiva/glimmer](https://github.com/AndyObtiva/glimmer)
9
+ [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.
10
+
11
+ You may find full setup/usage instructions at the main [Glimmer project page](https://github.com/AndyObtiva/glimmer).
12
+
13
+ Other Glimmer DSL gems:
14
+ - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
15
+ - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
16
+ - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
17
+
18
+ ## Example
19
+
20
+ ```ruby
21
+ include Glimmer
22
+
23
+ shell {
24
+ text 'Glimmer'
25
+ label {
26
+ text 'Hello, World!'
27
+ }
28
+ }.open
29
+ ```
30
+
31
+ ![Glimmer DSL for SWT Hello World](https://github.com/AndyObtiva/glimmer/blob/master/images/glimmer-hello-world.png)
32
+
33
+ Learn more at the main [Glimmer project page](https://github.com/AndyObtiva/glimmer).
9
34
 
10
35
  ## Help
11
36
 
@@ -15,11 +40,9 @@ You may submit [issues](https://github.com/AndyObtiva/glimmer/issues) on [GitHub
15
40
 
16
41
  [Click here to submit an issue.](https://github.com/AndyObtiva/glimmer/issues)
17
42
 
18
- ### IRC Channel
19
-
20
- If you need live help, try the [#glimmer](http://widget.mibbit.com/?settings=7514b8a196f8f1de939a351245db7aa8&server=irc.mibbit.net&channel=%23glimmer) IRC channel on [irc.mibbit.net](http://widget.mibbit.com/?settings=7514b8a196f8f1de939a351245db7aa8&server=irc.mibbit.net&channel=%23glimmer). If no one was available, you may [leave a GitHub issue](https://github.com/AndyObtiva/glimmer/issues) to schedule a meetup on IRC.
43
+ ### Chat
21
44
 
22
- [Click here to connect to #glimmer IRC channel immediately via a web interface.](http://widget.mibbit.com/?settings=7514b8a196f8f1de939a351245db7aa8&server=irc.mibbit.net&channel=%23glimmer)
45
+ If you need live help, try to [![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)
23
46
 
24
47
  ## Feature Suggestions
25
48
 
@@ -1 +1 @@
1
- jruby-9.2.11.1
1
+ jruby-9.2.12.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.2
Binary file
@@ -3,11 +3,18 @@ require 'glimmer/swt/packages'
3
3
  module Glimmer
4
4
  class << self
5
5
  def included(klass)
6
+ if Object.const_defined?(:ActiveSupport) && ActiveSupport.const_defined?(:Dependencies)
7
+ begin
8
+ ActiveSupport::Dependencies.unhook!
9
+ rescue => e
10
+ # noop TODO support logging unimportant details below debug level
11
+ end
12
+ end
6
13
  if Config.import_swt_packages
7
14
  klass.include(SWT::Packages)
8
15
  klass.extend(SWT::Packages)
9
- klass.extend(Glimmer)
10
16
  end
17
+ klass.extend(Glimmer)
11
18
  end
12
19
  end
13
20
  end
@@ -1,16 +1,24 @@
1
1
  module Glimmer
2
2
  module Config
3
+ DEFAULT_IMPORT_SWT_PACKAGES = [
4
+ 'org.eclipse.swt',
5
+ 'org.eclipse.swt.widgets',
6
+ 'org.eclipse.swt.layout',
7
+ 'org.eclipse.swt.graphics',
8
+ 'org.eclipse.swt.browser',
9
+ 'org.eclipse.swt.custom',
10
+ 'org.eclipse.swt.dnd',
11
+ ]
12
+
3
13
  class << self
4
14
  # Tells Glimmer to import SWT packages into including class (default: true)
5
15
  def import_swt_packages=(value)
6
- @@import_swt_packages = !!value
16
+ @@import_swt_packages = value
7
17
  end
8
18
 
9
19
  # Returns whether Glimmer will import SWT packages into including class
10
20
  def import_swt_packages
11
- unless defined? @@import_swt_packages
12
- @@import_swt_packages = true
13
- end
21
+ @@import_swt_packages = DEFAULT_IMPORT_SWT_PACKAGES if !defined?(@@import_swt_packages) || (defined?(@@import_swt_packages) && @@import_swt_packages == true)
14
22
  @@import_swt_packages
15
23
  end
16
24
  end
@@ -2,9 +2,14 @@ $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
2
2
 
3
3
  # External requires
4
4
  require 'java'
5
- require 'nested_inherited_jruby_include_package'
6
- require 'super_module'
7
- require 'glimmer'
5
+ if ENV['BUNDLER_REQUIRE'].to_s.downcase == 'true'
6
+ require 'bundler'
7
+ Bundler.require
8
+ else
9
+ require 'nested_inherited_jruby_include_package'
10
+ require 'super_module'
11
+ require 'glimmer'
12
+ end
8
13
 
9
14
  # Internal requires
10
15
  require 'ext/glimmer/config'
@@ -1,4 +1,3 @@
1
- require 'glimmer'
2
1
  require 'glimmer/data_binding/observable'
3
2
  require 'glimmer/data_binding/observer'
4
3
 
@@ -22,23 +22,24 @@ module Glimmer
22
22
  @table.body_root.column_properties = @column_properties
23
23
  end
24
24
  call(@model_binding.evaluate_property)
25
- model = model_binding.base_model
26
- observe(model, model_binding.property_name_expression)
25
+ observe(model_binding)
27
26
  @table.on_widget_disposed do |dispose_event|
28
27
  unregister_all_observables
29
28
  end
30
29
  end
31
30
 
32
31
  def call(new_model_collection=nil)
32
+ new_model_collection = @model_binding.evaluate_property # this ensures applying converters (e.g. :on_read)
33
33
  if new_model_collection and new_model_collection.is_a?(Array)
34
34
  observe(new_model_collection, @column_properties)
35
35
  @model_collection = new_model_collection
36
36
  end
37
- populate_table(@model_collection, @table, @column_properties)
37
+ populate_table(@model_collection, @table, @column_properties)
38
38
  end
39
-
39
+
40
40
  def populate_table(model_collection, parent, column_properties)
41
41
  selected_table_item_models = parent.swt_widget.getSelection.map(&:getData)
42
+ parent.finish_edit!
42
43
  parent.swt_widget.removeAll
43
44
  model_collection.each do |model|
44
45
  table_item = TableItem.new(parent.swt_widget, SWT::SWTProxy[:none])
@@ -1,6 +1,5 @@
1
- require 'glimmer'
2
- require_relative 'observable'
3
- require_relative 'observer'
1
+ require 'glimmer/data_binding/observable'
2
+ require 'glimmer/data_binding/observer'
4
3
 
5
4
  module Glimmer
6
5
  module DataBinding
@@ -10,10 +9,10 @@ module Glimmer
10
9
  include Observer
11
10
 
12
11
  attr_reader :widget, :property
13
- def initialize(model, property, translator = nil)
14
- @widget = model
12
+ def initialize(widget, property, translator = nil)
13
+ @widget = widget
15
14
  @property = property
16
- @translator = translator || proc {|value| value}
15
+ @translator = translator || proc {|value| value} #TODO check on this it doesn't seem used
17
16
 
18
17
  if @widget.respond_to?(:dispose)
19
18
  @widget.on_widget_disposed do |dispose_event|
@@ -21,10 +20,12 @@ module Glimmer
21
20
  end
22
21
  end
23
22
  end
23
+
24
24
  def call(value)
25
25
  converted_value = translated_value = @translator.call(value)
26
26
  @widget.set_attribute(@property, converted_value) unless evaluate_property == converted_value
27
27
  end
28
+
28
29
  def evaluate_property
29
30
  @widget.get_attribute(@property)
30
31
  end
@@ -35,6 +35,10 @@ module Glimmer
35
35
  parent.on_widget_selected do
36
36
  model_binding.call(widget_binding.evaluate_property)
37
37
  end
38
+
39
+ parent.on_modify_text do
40
+ model_binding.call(widget_binding.evaluate_property)
41
+ end
38
42
  end
39
43
  end
40
44
  end
@@ -0,0 +1,25 @@
1
+ require 'glimmer/dsl/static_expression'
2
+ require 'glimmer/swt/dnd_proxy'
3
+
4
+ # TODO consider turning static keywords like bind into methods
5
+
6
+ module Glimmer
7
+ module DSL
8
+ module SWT
9
+ # Responsible for returning DND constant values
10
+ #
11
+ # Named DndExpression (not DNDExpression) so that the DSL engine
12
+ # discovers quickly by convention
13
+ class DndExpression < StaticExpression
14
+ def can_interpret?(parent, keyword, *args, &block)
15
+ block.nil? &&
16
+ args.size > 0
17
+ end
18
+
19
+ def interpret(parent, keyword, *args, &block)
20
+ Glimmer::SWT::DNDProxy[*args]
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -14,10 +14,6 @@ module Glimmer
14
14
 
15
15
  include_package 'org.eclipse.swt.widgets'
16
16
 
17
- def can_interpret?(parent, keyword, *args, &block)
18
- keyword == 'message_box'
19
- end
20
-
21
17
  def interpret(parent, keyword, *args, &block)
22
18
  potential_parent = args.first
23
19
  parent = args.shift if potential_parent.is_a?(Shell) || (potential_parent.respond_to?(:swt_widget) && potential_parent.swt_widget.is_a?(Shell))
@@ -1,5 +1,7 @@
1
1
  require 'os'
2
2
 
3
+ # TODO refactor to nest under RakeTask namespace
4
+
3
5
  module Glimmer
4
6
  module Package
5
7
  class << self
@@ -59,4 +59,26 @@ namespace :glimmer do
59
59
  Scaffold.custom_widget_gem(args[:custom_widget_name], args[:namespace])
60
60
  end
61
61
  end
62
+
63
+ namespace :list do
64
+ task :list_require do
65
+ require_relative 'rake_task/list'
66
+ end
67
+
68
+ desc 'List Glimmer custom widget gems available at rubygems.org (query is optional)'
69
+ task :custom_widget_gems, [:query] => :list_require do |t, args|
70
+ Glimmer::RakeTask::List.custom_widget_gems(args[:query])
71
+ end
72
+
73
+ desc 'List Glimmer custom shell gems available at rubygems.org (query is optional)'
74
+ task :custom_shell_gems, [:query] => :list_require do |t, args|
75
+ Glimmer::RakeTask::List.custom_shell_gems(args[:query])
76
+ end
77
+
78
+ desc 'List Glimmer DSL gems available at rubygems.org (query is optional)'
79
+ task :dsl_gems, [:query] => :list_require do |t, args|
80
+ Glimmer::RakeTask::List.dsl_gems(args[:query])
81
+ end
82
+
83
+ end
62
84
  end
@@ -0,0 +1,73 @@
1
+ require 'facets'
2
+ require 'text-table'
3
+
4
+ module Glimmer
5
+ module RakeTask
6
+ # Lists Glimmer related gems to use in rake_task.rb
7
+ class List
8
+ class << self
9
+ REGEX_GEM_LINE = /^([^\(]+) \(([^\)]+)\)$/
10
+
11
+ def custom_widget_gems(query=nil)
12
+ list_gems('glimmer-cw-', query) do |result|
13
+ puts
14
+ puts " Glimmer Custom Widget Gems#{" matching [#{query}]" if query} at rubygems.org:"
15
+ puts result
16
+ end
17
+ end
18
+
19
+ def custom_shell_gems(query=nil)
20
+ list_gems('glimmer-cs-', query) do |result|
21
+ puts
22
+ puts " Glimmer Custom Shell Gems#{" matching [#{query}]" if query} at rubygems.org:"
23
+ puts result
24
+ end
25
+ end
26
+
27
+ def dsl_gems(query=nil)
28
+ list_gems('glimmer-dsl-', query) do |result|
29
+ puts
30
+ puts " Glimmer DSL Gems#{" matching [#{query}]" if query} at rubygems.org:"
31
+ puts result
32
+ end
33
+ end
34
+
35
+ def list_gems(gem_prefix, query=nil, &printer)
36
+ lines = `gem search -d #{gem_prefix}`.split("\n")
37
+ gems = lines.slice_before {|l| l.match(REGEX_GEM_LINE) }.to_a
38
+ gems = gems.map do |gem|
39
+ {
40
+ name: gem[0].match(REGEX_GEM_LINE)[1],
41
+ version: gem[0].match(REGEX_GEM_LINE)[2],
42
+ author: gem[1].strip,
43
+ description: gem[4..-1].map(&:strip).join(' ')
44
+ }
45
+ end.select do |gem|
46
+ query.nil? || "#{gem[:name]} #{gem[:author]} #{gem[:description]}".downcase.include?(query.to_s.downcase)
47
+ end
48
+ printer.call(tablify(gem_prefix, gems))
49
+ end
50
+
51
+ def tablify(gem_prefix, gems)
52
+ array_of_arrays = gems.map do |gem|
53
+ [
54
+ gem[:name].sub(gem_prefix, '').underscore.titlecase,
55
+ gem[:name],
56
+ gem[:version],
57
+ gem[:author].sub('Author: ', ''),
58
+ gem[:description],
59
+ ]
60
+ end
61
+ Text::Table.new(
62
+ :head => %w[Name Gem Version Author Description],
63
+ :rows => array_of_arrays,
64
+ :horizontal_padding => 1,
65
+ :vertical_boundary => ' ',
66
+ :horizontal_boundary => ' ',
67
+ :boundary_intersection => ' '
68
+ )
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -2,6 +2,8 @@ require 'fileutils'
2
2
  require 'os'
3
3
  require 'facets'
4
4
 
5
+ # TODO refactor to nest under RakeTask namespace
6
+
5
7
  class Scaffold
6
8
  class << self
7
9
  include FileUtils
@@ -56,7 +58,7 @@ class Scaffold
56
58
 
57
59
  # for a library or gem, you might want to ignore these files since the code is
58
60
  # intended to run in multiple environments; otherwise, check them in:
59
- Gemfile.lock
61
+ # Gemfile.lock
60
62
  # .ruby-version
61
63
  # .ruby-gemset
62
64
 
@@ -0,0 +1,34 @@
1
+ require 'glimmer/swt/style_constantizable'
2
+
3
+ module Glimmer
4
+ module SWT
5
+ # Proxy for org.eclipse.swt.dnd.DND
6
+ #
7
+ # Follows the Proxy Design Pattern
8
+ class DNDProxy
9
+ include StyleConstantizable
10
+
11
+ class << self
12
+ JAVA_IMPORT = 'org.eclipse.swt.dnd.DND'
13
+
14
+ java_import JAVA_IMPORT
15
+
16
+ def constant_java_import
17
+ JAVA_IMPORT
18
+ end
19
+
20
+ def constant_source_class
21
+ DND
22
+ end
23
+
24
+ def constant_value_none
25
+ DND::DROP_NONE
26
+ end
27
+
28
+ def extra_styles
29
+ {}
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,13 +1,16 @@
1
+ require 'ext/glimmer/config'
2
+
1
3
  module Glimmer
2
4
  module SWT
3
5
  # This contains Java imports of SWT Java packages
4
6
  module Packages
5
- include_package 'org.eclipse.swt'
6
- include_package 'org.eclipse.swt.widgets'
7
- include_package 'org.eclipse.swt.layout'
8
- include_package 'org.eclipse.swt.graphics'
9
- include_package 'org.eclipse.swt.browser'
10
- include_package 'org.eclipse.swt.custom'
7
+ class << self
8
+ def included(klass)
9
+ Glimmer::Config.import_swt_packages.to_a.each do |package|
10
+ include_package(package) if package.is_a?(String)
11
+ end
12
+ end
13
+ end
11
14
  end
12
15
  end
13
16
  end