glimmer 0.7.0 → 0.7.1

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: a2c1935b1d8ac63f8f79323e754e9a32a6c3ed8465db80da479a36e28f377d7a
4
- data.tar.gz: 1b64ca831d6d2b911278abfd6156fa6267a9a88b82bc8a5a5a4bf7b35c09c403
3
+ metadata.gz: 31b586dfb4cb23af36ebd26ad97a46625fe122c64d9725b237c8f88f0c72ce71
4
+ data.tar.gz: 14ff7f5996588c4261cf4d102d5ffca28fc59cef5bd151d07c273038efae3da5
5
5
  SHA512:
6
- metadata.gz: ccab304701eefa5bcd8560995878b2f50cf739f6ec092244b5a0bfdc686e15859f81f74c62939beaccb0efd5052a126adfe2dbde887afb13d697af7430b68f7f
7
- data.tar.gz: 1ba3e00febd0b60e3c9105b0737c4a875c438cc450048c7cc49bc8d06a84eb0a311b3581d5c61845c3b0a17fd1ec7dbc554428d02b8d3853e048e14b3fcca9fb
6
+ metadata.gz: 6eb266dffd64ba21842038fd272c06a3342f3399b5729d178b966b9543dfdbb9eb45eea079782d0db205e68cc9b63a5a0a4222a9d77c9f5df2cacc01126fed51
7
+ data.tar.gz: 123a861f812ac0e4ee2e4c802255ff017c2459a65de79cb52863897a0b017fc8037d9b57eb8e041dc75005d68ee4a3835b07a7cd03f87c30f524c5fef67717ca
@@ -1,4 +1,5 @@
1
- # Glimmer 0.7.0 Beta (JRuby Desktop UI DSL + Data-Binding)
1
+ # Glimmer 0.7.1 Beta (JRuby Desktop UI DSL + Data-Binding)
2
+ [![Gem Version](https://badge.fury.io/rb/glimmer.svg)](http://badge.fury.io/rb/glimmer)
2
3
  [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer?branch=master)
3
4
 
4
5
  Glimmer is a native-UI 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 UI with domain models. As a result, that achieves true decoupling of object oriented components, enabling developers to solve business problems without worrying about UI concerns, or alternatively drive development UI-first, and then write clean business components test-first afterwards.
@@ -45,7 +46,7 @@ shell {
45
46
  text bind(@tic_tac_toe_board[row, column], :sign)
46
47
  enabled bind(@tic_tac_toe_board[row, column], :empty)
47
48
  on_widget_selected {
48
- @tic_tac_toe_board.mark_box(row, column)
49
+ @tic_tac_toe_board.mark(row, column)
49
50
  }
50
51
  }
51
52
  }
@@ -70,7 +71,7 @@ NOTE: Glimmer is in beta mode. Please help make better by adopting for small or
70
71
  ## Table of Contents
71
72
 
72
73
  <!-- TOC START min:1 max:3 link:true asterisk:false update:true -->
73
- - [Glimmer 0.7.0 Beta (JRuby Desktop UI DSL + Data-Binding)](#glimmer-058-beta-jruby-desktop-ui-dsl--data-binding)
74
+ - [Glimmer 0.7.1 Beta (JRuby Desktop UI DSL + Data-Binding)](#glimmer-058-beta-jruby-desktop-ui-dsl--data-binding)
74
75
  - [Examples](#examples)
75
76
  - [Hello World](#hello-world)
76
77
  - [Tic Tac Toe](#tic-tac-toe)
@@ -163,7 +164,7 @@ Please follow these instructions to make the `glimmer` command available on your
163
164
 
164
165
  Run this command to install directly:
165
166
  ```
166
- jgem install glimmer -v 0.7.0
167
+ jgem install glimmer -v 0.7.1
167
168
  ```
168
169
 
169
170
  `jgem` is JRuby's version of `gem` command.
@@ -174,7 +175,7 @@ Otherwise, you may also run `jruby -S gem install ...`
174
175
 
175
176
  Add the following to `Gemfile`:
176
177
  ```
177
- gem 'glimmer', '~> 0.7.0'
178
+ gem 'glimmer', '~> 0.7.1'
178
179
  ```
179
180
 
180
181
  And, then run:
@@ -226,6 +227,7 @@ glimmer package:jar # Generate JAR
226
227
  glimmer package:native # Generate Native files (DMG/PKG/APP on the Mac)
227
228
  glimmer scaffold[app_name] # Scaffold a Glimmer application directory structure to begin building a new app
228
229
  glimmer scaffold:custom_shell[custom_shell_name,namespace] # Scaffold a Glimmer::UI::CustomShell subclass (represents a full window view) under app/views (namespace is optional)
230
+ glimmer scaffold:custom_shell_gem[custom_widget_name,namespace] # Scaffold a Glimmer::UI::CustomShell subclass (represents a full window view) under its own Ruby gem project (namespace is required)
229
231
  glimmer scaffold:custom_widget[custom_widget_name,namespace] # Scaffold a Glimmer::UI::CustomWidget subclass (represents a part of a view) under app/views (namespace is optional)
230
232
  glimmer scaffold:custom_widget_gem[custom_widget_name,namespace] # Scaffold a Glimmer::UI::CustomWidget subclass (represents a part of a view) under its own Ruby gem project (namespace is required)
231
233
 
@@ -234,13 +236,13 @@ automatically preloading the glimmer Ruby gem and SWT jar dependency.
234
236
 
235
237
  Optionally, extra Glimmer options, JRuby options and environment variables may be passed in.
236
238
 
237
- Concerning Glimmer options:
239
+ Glimmer options:
238
240
  - "--debug" : Displays extra debugging information and passes "--debug" to JRuby
239
241
  - "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is "WARN")
240
242
 
241
- Example: glimmer samples/hello/hello_world.rb
243
+ Example: glimmer samples/hello_world.rb
242
244
 
243
- This runs the Glimmer application samples/hello/hello_world.rb
245
+ This runs the Glimmer application samples/hello_world.rb
244
246
  ```
245
247
 
246
248
  Example (Glimmer/JRuby option specified):
@@ -262,7 +264,7 @@ Launches samples/hello/hello_world.rb and samples/hello_tab.rb at the same time,
262
264
  Glimmer borrows from Rails the idea of Scaffolding, that is generating a structure for your app files that
263
265
  helps you get started just like true building scaffolding helps construction workers, civil engineers, and architects.
264
266
 
265
- Glimmer scaffolding goes way beyond just scaffolding the app files that Rails does. It also packages it and launches it,
267
+ Glimmer scaffolding goes beyond just scaffolding the app files that Rails does. It also packages it and launches it,
266
268
  getting you to a running and delivered state of an advanced "Hello, World!" Glimmer application right off the bat.
267
269
 
268
270
  This should greatly facilitate building a new Glimmer app by helping you be productive and focus on app details while
@@ -276,6 +278,8 @@ letting Glimmer scaffolding take care of initial app file structure concerns, su
276
278
  - Icon
277
279
  - Bin file for starting application
278
280
 
281
+ NOTE: Scaffolding currently supports Mac packaging only at the moment.
282
+
279
283
  #### App
280
284
 
281
285
  Before you start, make sure you are in a JRuby environment with Glimmer gem installed as per "Direct Install" pre-requisites.
@@ -344,7 +348,7 @@ It is important to specify a namespace to avoid having your gem clash with exist
344
348
 
345
349
  The Ruby gem name will follow the convention "glimmer-cs-customwidgetname-namespace" (the 'cs' is for Custom Shell)
346
350
 
347
- Only official Glimmer gems created by the Glimmer project committers will have no namespace (e.g. "glimmer-cs-gladiator" Ruby gem)
351
+ Only official Glimmer gems created by the Glimmer project committers will have no namespace (e.g. [glimmer-cs-gladiator](https://rubygems.org/gems/glimmer-cs-gladiator) Ruby gem)
348
352
 
349
353
  Example: [https://github.com/AndyObtiva/glimmer-cs-gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator)
350
354
 
@@ -360,7 +364,7 @@ It is important to specify a namespace to avoid having your gem clash with exist
360
364
 
361
365
  The Ruby gem name will follow the convention "glimmer-cw-customwidgetname-namespace" (the 'cw' is for Custom Widget)
362
366
 
363
- Only official Glimmer gems created by the Glimmer project committers will have no namespace (e.g. "glimmer-cw-video" Ruby gem)
367
+ Only official Glimmer gems created by the Glimmer project committers will have no namespace (e.g. [glimmer-cw-video](https://rubygems.org/gems/glimmer-cw-video) Ruby gem)
364
368
 
365
369
  Example: [https://github.com/AndyObtiva/glimmer-cw-video](https://github.com/AndyObtiva/glimmer-cw-video)
366
370
 
@@ -424,7 +428,7 @@ In Glimmer DSL, widgets are declared with lowercase underscored names mirroring
424
428
  - `list` instantiates `org.eclipse.swt.widgets.List`
425
429
 
426
430
  Every **widget** is sufficiently declared by name, but may optionally be accompanied with:
427
- - SWT **style** ***argument*** wrapped by parenthesis according to [Glimmer Style Guide](#glimmer-coding-style) (see [next section](#widget-styles) for details).
431
+ - SWT **style** ***argument*** wrapped by parenthesis according to [Glimmer Style Guide](#glimmer-style-guide) (see [next section](#widget-styles) for details).
428
432
  - Ruby block containing **properties** (widget attributes) and **content** (nested widgets)
429
433
 
430
434
  For example, if we were to revisit `samples/hello/hello_world.rb` above (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
@@ -451,7 +455,7 @@ Note that `shell` instantiates the outer shell **widget**, in other words, the w
451
455
  # ...
452
456
  ```
453
457
 
454
- The first line declares a **property** called `text`, which sets the title of the shell (window) to `"Glimmer"`. **Properties** always have ***arguments*** (not wrapped by parenthesis according to [Glimmer Style Guide](#glimmer-coding-style)), such as the text `"Glimmer"` in this case, and do **NOT** have a ***block*** (this distinguishes them from **widget** declarations).
458
+ The first line declares a **property** called `text`, which sets the title of the shell (window) to `"Glimmer"`. **Properties** always have ***arguments*** (not wrapped by parenthesis according to [Glimmer Style Guide](#glimmer-style-guide)), such as the text `"Glimmer"` in this case, and do **NOT** have a ***block*** (this distinguishes them from **widget** declarations).
455
459
 
456
460
  The second line declares the `label` **widget**, which is followed by a Ruby **content** ***block*** that contains its `text` **property** with value `"Hello, World!"`
457
461
 
@@ -690,7 +694,7 @@ SWT widgets receive `SWT` styles in their constructor as per this guide:
690
694
 
691
695
  https://wiki.eclipse.org/SWT_Widget_Style_Bits
692
696
 
693
- Glimmer DSL facilitates that by passing symbols representing `SWT` constants as widget method arguments (i.e. inside widget `()` parentheses according to [Glimmer Style Guide](#glimmer-coding-style). See example below) in lower case version (e.g. `SWT::MULTI` becomes `:multi`).
697
+ Glimmer DSL facilitates that by passing symbols representing `SWT` constants as widget method arguments (i.e. inside widget `()` parentheses according to [Glimmer Style Guide](#glimmer-style-guide). See example below) in lower case version (e.g. `SWT::MULTI` becomes `:multi`).
694
698
 
695
699
  These styles customize widget look, feel, and behavior.
696
700
 
@@ -1817,6 +1821,15 @@ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1817
1821
  puts @css
1818
1822
  ```
1819
1823
 
1824
+ ##### Listing / Enabling / Disabling DSLs
1825
+
1826
+ Glimmer provides a number of methods on Glimmer::DSL::Engine to configure DSL support or inquire about it:
1827
+ - `Glimmer::DSL::Engine.dsls`: Lists available Glimmer DSLs
1828
+ - `Glimmer::DSL::Engine.disable_dsl(dsl_name)`: Disables a specific DSL. Useful when there is no need for certain DSLs in a certain application.
1829
+ - `Glimmer::DSL::Engine.disabled_dsls': Lists disabled DSLs
1830
+ - `Glimmer::DSL::Engine.enable_dsl(dsl_name)`: Re-enables disabled DSL
1831
+ - `Glimmer::DSL::Engine.enabled_dsls=(dsl_names)`: Disables all DSLs except the ones specified.
1832
+
1820
1833
  #### Video Widget
1821
1834
 
1822
1835
  ![Video Widget](images/glimmer-video-widget.png)
@@ -1968,7 +1981,7 @@ For example, after imports, `org.eclipse.swt.graphics.Color` can be referenced b
1968
1981
  Nonetheless, you can disable automatic import if needed via this Glimmer configuration option:
1969
1982
 
1970
1983
  ```ruby
1971
- Glimmer.import_swt_packages = false
1984
+ Glimmer::Config.import_swt_packages = false
1972
1985
  ```
1973
1986
 
1974
1987
  To import SWT Java packages manually instead, you have 2 options:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
data/bin/girb CHANGED
@@ -1,5 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ trap "SIGINT" do
4
+ # No Op for irb
5
+ end
6
+
3
7
  require_relative '../lib/glimmer/launcher'
4
8
 
5
9
  girb_runner = File.expand_path('../girb_runner.rb', __FILE__)
@@ -1,3 +1,13 @@
1
1
  require 'puts_debuggerer'
2
2
 
3
3
  include Glimmer
4
+
5
+ # Hijack Shell#start_event_loop default behavior to ensure disposing a display upon closing a shell inside girb
6
+
7
+ Glimmer::SWT::ShellProxy.class_eval do
8
+ alias start_event_loop_original start_event_loop
9
+ def start_event_loop
10
+ start_event_loop_original
11
+ Glimmer::SWT::DisplayProxy.instance.dispose
12
+ end
13
+ end
@@ -11,6 +11,11 @@ module Glimmer
11
11
  def remove_observer(observer, property_or_properties=nil)
12
12
  raise Error, 'Not implemented!'
13
13
  end
14
+
15
+ # Overriding inspect to avoid printing very long observer hierarchies
16
+ def inspect
17
+ "#<#{self.class.name}:0x#{self.hash.to_s(16)}>"
18
+ end
14
19
  end
15
20
  end
16
21
  end
@@ -49,7 +49,9 @@ module Glimmer
49
49
 
50
50
  # Resets Glimmer's engine activity and configuration. Useful in rspec before or after blocks in tests.
51
51
  def reset
52
- parent_stack.clear
52
+ parent_stacks.values.each do |a_parent_stack|
53
+ a_parent_stack.clear
54
+ end
53
55
  dsl_stack.clear
54
56
  disabled_dsls.clear
55
57
  end
@@ -96,7 +98,8 @@ module Glimmer
96
98
  if retrieved_static_expression.nil? && Glimmer::DSL::Engine.dsl && (static_expression_dsl.nil? || !Glimmer::DSL::Engine.static_expressions[keyword][static_expression_dsl].is_a?(TopLevelExpression))
97
99
  begin
98
100
  return Glimmer::DSL::Engine.interpret(keyword, *args, &block)
99
- rescue => e
101
+ rescue => e
102
+ Glimmer::DSL::Engine.reset
100
103
  raise e if static_expression_dsl.nil?
101
104
  end
102
105
  end
@@ -113,7 +116,8 @@ module Glimmer
113
116
  end
114
117
  end
115
118
  rescue => e
116
- Glimmer::DSL::Engine.dsl_stack.pop
119
+ # Glimmer::DSL::Engine.dsl_stack.pop
120
+ Glimmer::DSL::Engine.reset
117
121
  raise e
118
122
  end
119
123
  end
@@ -138,7 +142,8 @@ module Glimmer
138
142
  dsl_stack.pop
139
143
  end
140
144
  rescue => e
141
- dsl_stack.pop
145
+ # dsl_stack.pop
146
+ reset
142
147
  raise e
143
148
  end
144
149
 
@@ -9,6 +9,11 @@ module Glimmer
9
9
  class ShellExpression < StaticExpression
10
10
  include TopLevelExpression
11
11
  include ParentExpression
12
+
13
+ def can_interpret?(parent, keyword, *args, &block)
14
+ keyword == 'shell' and
15
+ (parent.nil? or parent.is_a?(Glimmer::SWT::ShellProxy))
16
+ end
12
17
 
13
18
  def interpret(parent, keyword, *args, &block)
14
19
  args = [parent] + args unless parent.nil?
@@ -328,7 +328,7 @@ class Scaffold
328
328
  def spec_helper_file
329
329
  content = File.read('spec/spec_helper.rb')
330
330
  lines = content.split("\n")
331
- require_line_index = lines.index(lines.detect {|l| l.include?('glimmer-cw-video') })
331
+ require_line_index = lines.index(lines.detect {|l| l.include?(current_dir_name) })
332
332
  lines[require_line_index...require_line_index] = [
333
333
  "require 'bundler/setup'",
334
334
  'Bundler.require(:default, :development)',
@@ -39,6 +39,14 @@ module Glimmer
39
39
  @display ||= @swt_widget.getDisplay
40
40
  @swt_widget.setLayout(FillLayout.new)
41
41
  @swt_widget.setMinimumSize(WIDTH_MIN, HEIGHT_MIN)
42
+ on_event_show do
43
+ Thread.new do
44
+ sleep(0.25)
45
+ async_exec do
46
+ @swt_widget.setActive
47
+ end
48
+ end
49
+ end
42
50
  end
43
51
 
44
52
  # Centers shell within monitor it is in
@@ -172,6 +172,13 @@ module Glimmer
172
172
  }
173
173
  end
174
174
  },
175
+ Java::OrgEclipseSwtWidgets::MenuItem => {
176
+ :selection => proc do |observer|
177
+ on_widget_selected { |selection_event|
178
+ observer.call(@swt_widget.getSelection)
179
+ }
180
+ end
181
+ },
175
182
  Java::OrgEclipseSwtWidgets::Spinner => {
176
183
  :selection => proc do |observer|
177
184
  on_widget_selected { |selection_event|
@@ -231,7 +238,7 @@ module Glimmer
231
238
  def add_observer(observer, property_name)
232
239
  property_listener_installers = @swt_widget.class.ancestors.map {|ancestor| widget_property_listener_installers[ancestor]}.compact
233
240
  widget_listener_installers = property_listener_installers.map{|installer| installer[property_name.to_s.to_sym]}.compact if !property_listener_installers.empty?
234
- widget_listener_installers.each do |widget_listener_installer|
241
+ widget_listener_installers.to_a.each do |widget_listener_installer|
235
242
  widget_listener_installer.call(observer)
236
243
  end
237
244
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-03 00:00:00.000000000 Z
11
+ date: 2020-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -111,24 +111,24 @@ dependencies:
111
111
  - !ruby/object:Gem::Dependency
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - "~>"
114
+ - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 3.5.0
117
- name: rspec-mocks
118
- type: :development
116
+ version: 6.2.1
117
+ name: rdoc
118
+ type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 3.5.0
124
+ version: 6.2.1
125
125
  - !ruby/object:Gem::Dependency
126
126
  requirement: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
130
  version: 3.5.0
131
- name: rspec
131
+ name: rspec-mocks
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
@@ -141,15 +141,15 @@ dependencies:
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: 2.3.0
145
- name: rdoc
144
+ version: 3.5.0
145
+ name: rspec
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 2.3.0
152
+ version: 3.5.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  requirement: !ruby/object:Gem::Requirement
155
155
  requirements: