glimmer-cw-cdatetime-nebula 1.4.0.1 → 1.4.0.2.0

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: 69a8e6e32c80b91fce577118bd5f5eeb19dd0f30748e5b524e7f568f8b915a52
4
- data.tar.gz: efefaf44e19b27f5177140403c6352bb33cdde12e42bbd78fa081746148f164d
3
+ metadata.gz: b37eeaba86e192bbf3f0e00c57b267ab0c56e6574c310567489c23f1837c2190
4
+ data.tar.gz: 33f2acdd08fad52407236b598046aad6da491bdd61adc95c31ca89781acca617
5
5
  SHA512:
6
- metadata.gz: 4632c85efeb1f6ef23c0847606e0e93911ef3367cbb3c7aa283bb0e64baf75860a289d9221619711a6596fe476130996ed7adfc8fcd6c701a0d33d0e16d74f21
7
- data.tar.gz: 81151d0176099eac6c53d7fc14b331f734a7ba07526810885d38a500e70ee3e266f2f229347c7449acaa3eb43d6deac90ce22860f1d6ed90282e6fc2a1673f0c
6
+ metadata.gz: 173b9ff49a578b5e5952eb88513c6b5bf5518eb47036d915bbfc52bba7ce90906d93f6b4cb1cb1e7f825f9c22bca4c78bfb99263bb182d0021f96b146802eec4
7
+ data.tar.gz: a0b93d1badec9d7054197b44bfc3610b0f6ad0b8c5c329ae920c0d1ea083311c3335e7849ee0f32570b8b98eba7c5de60728347033f6ad9bb2d9054c89582864
data/README.md CHANGED
@@ -1,22 +1,53 @@
1
- # Nebula CDateTime Widget 1.4.0.1
1
+ # Nebula CDateTime Widget 1.4.0.2.0
2
2
  ## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer Custom Widget](https://github.com/AndyObtiva/glimmer#custom-widget-gem)
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-cw-cdatetime-nebula.svg)](http://badge.fury.io/rb/glimmer-cw-cdatetime-nebula)
4
4
 
5
5
  [<img alt="Nebula CDateTime Widget" src="https://www.eclipse.org/nebula/widgets/cdatetime/images/CDTSnippet02.png" />](https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php)
6
6
 
7
- The [Nebula CDateTime Widget](https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php) is a Date and Time selection widget that can be used in a textual, graphical, or combo mode.
7
+ The [Nebula CDateTime Widget](https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php) is a Date and Time selection widget that can be used in a plain (graphical), dropdown, spinner, or compact text style.
8
8
 
9
9
  Packaged as a [Glimmer Custom Widget](https://github.com/AndyObtiva/glimmer#custom-widget-gem) to provide date/time selection via a combo/dropdown-style widget in [Glimmer](https://github.com/AndyObtiva/glimmer) using the `c_date_time` [Glimmer DSL](https://github.com/AndyObtiva/glimmer#glimmer-dsl-syntax) keyword.
10
10
 
11
- [glimmer-cw-cdatetime-nebula](https://rubygems.org/gems/glimmer-cw-cdatetime-nebula) 1.4.0.x gem versions map to Nebula CDateTime Widget version 1.4.0
12
-
13
- ## Java Imports
14
-
15
- [glimmer-cw-cdatetime-nebula](https://rubygems.org/gems/glimmer-cw-cdatetime-nebula) includes and imports the following Java JAR libraries:
16
- - 'vendor/nebula/org.eclipse.nebula.cwt_1.1.0.jar'
17
- - 'vendor/nebula/org.eclipse.nebula.widgets.cdatetime_1.4.0.jar'
18
-
19
- It also configures them in [Glimmer](https://github.com/AndyObtiva/glimmer) for auto import via JRuby `include_package` on first use.
11
+ [glimmer-cw-cdatetime-nebula](https://rubygems.org/gems/glimmer-cw-cdatetime-nebula) 1.4.0.x.y gem versions map to Nebula CDateTime Widget version 1.4.0
12
+
13
+ ## Table of contents
14
+
15
+ - [Nebula CDateTime Widget 1.4.0.2.0](#nebula-cdatetime-widget-14020)
16
+ - [Pre-requisites](#pre-requisites)
17
+ - [Setup](#setup)
18
+ - [Glimmer Application](#glimmer-application)
19
+ - [Glimmer Custom Shell or Glimmer Custom Widget](#glimmer-custom-shell-or-glimmer-custom-widget)
20
+ - [Java Imports](#java-imports)
21
+ - [Instructions](#instructions)
22
+ - [Sample](#sample)
23
+ - [Plain](#plain)
24
+ - [`c_date_time`](#cdatetime)
25
+ - [`c_date`](#cdate)
26
+ - [`c_time`](#ctime)
27
+ - [Drop Down](#drop-down)
28
+ - [`c_date_time_drop_down`](#cdatetimedropdown)
29
+ - [`c_date_drop_down`](#cdatedropdown)
30
+ - [`c_time_drop_down`](#ctimedropdown)
31
+ - [Spinner](#spinner)
32
+ - [`c_date_time_spinner`](#cdatetimespinner)
33
+ - [`c_date_spinner`](#cdatespinner)
34
+ - [`c_time_spinner`](#ctimespinner)
35
+ - [Compact](#compact)
36
+ - [`c_date_time_compact`](#cdatetimecompact)
37
+ - [`c_date_compact`](#cdatecompact)
38
+ - [`c_time_compact`](#ctimecompact)
39
+ - [Style](#style)
40
+ - [`cdt`](#cdt)
41
+ - [Data-Binding and Observers:](#data-binding-and-observers)
42
+ - [Table Editing](#table-editing)
43
+ - [API](#api)
44
+ - [Glimmer Custom API](#glimmer-custom-api)
45
+ - [`toggle_open`](#toggleopen)
46
+ - [`text_widget_proxy`](#textwidgetproxy)
47
+ - [TODO](#todo)
48
+ - [Change Log](#change-log)
49
+ - [Contributing to glimmer-cw-cdatetime-nebula](#contributing-to-glimmer-cw-cdatetime-nebula)
50
+ - [Copyright](#copyright)
20
51
 
21
52
  ## Pre-requisites
22
53
 
@@ -26,12 +57,16 @@ It also configures them in [Glimmer](https://github.com/AndyObtiva/glimmer) for
26
57
 
27
58
  ## Setup
28
59
 
60
+ Versions follow this convention:
61
+ - First 3 digits map to the official Nebula CDateTime library version (e.g. 1.4.0)
62
+ - Last 2 digits map to minor and patch versions for Glimmer Custom Widget wrapper
63
+
29
64
  ### Glimmer Application
30
65
 
31
66
  Add the following to a [Glimmer](https://github.com/AndyObtiva/glimmer) application `Gemfile`:
32
67
 
33
68
  ```ruby
34
- gem 'glimmer-cw-cdatetime-nebula', '1.4.0.1'
69
+ gem 'glimmer-cw-cdatetime-nebula', '1.4.0.2.0'
35
70
  ```
36
71
 
37
72
  Run:
@@ -40,41 +75,170 @@ Run:
40
75
  jruby -S bundle
41
76
  ```
42
77
 
43
- (or just `bundle` if using RVM)
78
+ (or just `bundle` if using [RVM)
44
79
 
45
80
  ### Glimmer Custom Shell or Glimmer Custom Widget
46
81
 
47
- When reusing in a [Glimmer](https://github.com/AndyObtiva/glimmer) custom shell or custom widget, you can follow the same steps for Glimmer application, and then add a require statement to your library file after `glimmer` and before additional library require statements:
82
+ When reusing in a [Glimmer](https://github.com/AndyObtiva/glimmer) custom shell or custom widget, you can follow the same steps for Glimmer application, and then add a require statement to your library file after `glimmer-dsl-swt` and before additional library require statements:
48
83
 
49
84
  ```ruby
50
- require 'glimmer'
85
+ require 'glimmer-dsl-swt'
51
86
  require 'glimmer-cw-cdatetime-nebula'
52
87
  # ... more require statements follow
53
88
  ```
54
89
 
55
- ## Instructions
90
+ ### Java Imports
56
91
 
57
- `c_date_time` is the [Glimmer DSL](https://github.com/AndyObtiva/glimmer#glimmer-dsl-syntax) keyword to use.
92
+ Requiring the gem automatically configures java imports in [Glimmer](https://github.com/AndyObtiva/glimmer) for auto import via [JRuby](https://www.jruby.org/) `include_package` on first use:
93
+ - `org.eclipse.nebula.cwt`
94
+ - `org.eclipse.nebula.widgets.cdatetime`
58
95
 
59
- Further instructions may be found at the [Nebula CDateTime Widget homepage](https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php):
96
+ ## Usage Instructions
60
97
 
61
- [https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php](https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php)
98
+ This [glimmer-cw-cdatetime-nebula](https://rubygems.org/gems/glimmer-cw-cdatetime-nebula) gem adds the `c_date_time` keyword to the [Glimmer GUI DSL](https://github.com/AndyObtiva/glimmer#glimmer-dsl-syntax) as well as other alias keywords as explained below.
62
99
 
63
- ## API
100
+ The `c_date_time` keyword takes [`CDT`](#cdt) style bits as arguments.
101
+
102
+ Example:
103
+
104
+ ```ruby
105
+ c_date_time(:border, :compact, :drop_down, :date_long)
106
+ ```
107
+
108
+ Further instructions may be found at the [Nebula CDateTime Widget homepage](https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php).
109
+
110
+ ### Sample
111
+
112
+ Please run the following command to launch the [Nebula CDateTime Glimmer Custom Widget Gallery](samples/nebula/c_date_time_gallery.rb) app:
113
+
114
+ ```
115
+ glimmer sample:run[c_date_time_gallery]
116
+ ```
117
+
118
+ ### Plain
119
+
120
+ ![plain screenshot](images/glimmer-cw-cdatetime-nebula-plain.png)
121
+
122
+ #### `c_date_time`
123
+
124
+ Main keyword representing the Nebula CDateTime custom widget. Defaults to date/time pattern `'MM/dd/yyyy hh:mm a'` and plain style with a border
125
+
126
+ #### `c_date`
127
+
128
+ Alias keyword that specifies date pattern `'MM/dd/yyyy'` and plain style with a border
129
+
130
+ #### `c_time`
131
+
132
+ Alias keyword that specifies time pattern `'hh:mm a'` and plain style with a border
133
+
134
+ ### Drop Down
135
+
136
+ ![plain screenshot](images/glimmer-cw-cdatetime-nebula-drop-down.png)
137
+
138
+ #### `c_date_time_drop_down`
139
+
140
+ Alias keyword that specifies date/time pattern `'MM/dd/yyyy hh:mm a'` and drop down style with a border
141
+
142
+ ![plain screenshot](images/glimmer-cw-cdatetime-nebula-drop-down-date-time.png)
143
+
144
+ #### `c_date_drop_down`
145
+
146
+ Alias keyword that specifies date pattern `'MM/dd/yyyy'` and drop down style with a border
147
+
148
+ ![plain screenshot](images/glimmer-cw-cdatetime-nebula-drop-down-date.png)
149
+
150
+ #### `c_time_drop_down`
151
+
152
+ Alias that specifies time pattern `'hh:mm a'` and drop down style with a border
153
+
154
+ ![plain screenshot](images/glimmer-cw-cdatetime-nebula-drop-down-time.png)
155
+
156
+ ### Spinner
157
+
158
+ ![plain screenshot](images/glimmer-cw-cdatetime-nebula-spinner.png)
159
+
160
+ #### `c_date_time_spinner`
161
+
162
+ Alias that specifies date/time pattern `'MM/dd/yyyy hh:mm a'` and spinner style with a border
163
+
164
+ #### `c_date_spinner`
165
+
166
+ Alias that specifies date pattern `'MM/dd/yyyy'` and spinner style with a border
167
+
168
+ #### `c_time_spinner`
169
+
170
+ Alias that specifies time pattern `'hh:mm a'` and spinner style with a border
171
+
172
+ ### Compact
173
+
174
+ ![plain screenshot](images/glimmer-cw-cdatetime-nebula-compact.png)
175
+
176
+ #### `c_date_time_compact`
64
177
 
65
- Here is the Nebula CDateTime Widget [Javadoc API page](https://www.eclipse.org/nebula/releases/latest/javadoc/org/eclipse/nebula/widgets/cdatetime/CDateTime.html):
178
+ Alias that specifies date/time pattern `'MM/dd/yyyy hh:mm a'` and compact style (just a text field) with a border
66
179
 
67
- [https://www.eclipse.org/nebula/releases/latest/javadoc/org/eclipse/nebula/widgets/cdatetime/CDateTime.html](https://www.eclipse.org/nebula/releases/latest/javadoc/org/eclipse/nebula/widgets/cdatetime/CDateTime.html)
180
+ #### `c_date_compact`
68
181
 
69
- ## Examples:
182
+ Alias that specifies date pattern `'MM/dd/yyyy'` and compact style (just a text field) with a border
70
183
 
71
- ### Example of using `c_date_time` widget:
184
+ #### `c_time_compact`
185
+
186
+ Alias that specifies time pattern `'hh:mm a'` and compact style (just a text field) with a border
187
+
188
+ ### Style
189
+
190
+ #### `cdt`
191
+
192
+ [`CDT`](https://www.eclipse.org/nebula/releases/latest/javadoc/org/eclipse/nebula/widgets/cdatetime/CDT.html) styles are fully documented in the [Nebula `CDT` Javadoc](https://www.eclipse.org/nebula/releases/latest/javadoc/org/eclipse/nebula/widgets/cdatetime/CDT.html).
193
+
194
+ The `cdt` keyword builds a [`CDT`](https://www.eclipse.org/nebula/releases/latest/javadoc/org/eclipse/nebula/widgets/cdatetime/CDT.html) style by passing in comma-separated symbols (e.g. `cdt(:border, :drop_down, :date_long)`)
195
+
196
+ For example, instead of passing style as bit-or'ed `CDT` Constant style bits:
197
+
198
+ ```ruby
199
+ c_date_time(CDT::BORDER | CDT::COMPACT | CDT::DROP_DOWN | CDT::DATE_LONG)
200
+ ```
201
+
202
+ You instead pass style as comma-separated symbols:
203
+
204
+ ```ruby
205
+ c_date_time(cdt(:border, :compact, :drop_down, :date_long))
206
+ ```
207
+
208
+ However, `c_date_time` goes one step further and uses it internally automatically by all `c_date_time` keyword initializers, so you could ditch the `cdt` entirely when constructing a widget.
209
+
210
+ ```ruby
211
+ c_date_time(:border, :compact, :drop_down, :date_long)
212
+ ```
213
+
214
+ Furthermore, `c_date_time` has pre-configured smart defaults for `CDT` styles:
215
+
216
+ ```
217
+ 'c_date_time' => [:border, :tab_fields, :simple],
218
+ 'c_date' => [:border, :tab_fields, :date_short, :simple],
219
+ 'c_time' => [:border, :tab_fields, :time_short, :simple],
220
+ 'c_date_time_compact' => [:border, :tab_fields, :compact],
221
+ 'c_date_compact' => [:border, :tab_fields, :date_short, :compact],
222
+ 'c_time_compact' => [:border, :tab_fields, :time_short, :compact],
223
+ 'c_date_time_spinner' => [:border, :tab_fields, :spinner],
224
+ 'c_date_spinner' => [:border, :tab_fields, :date_short, :spinner],
225
+ 'c_time_spinner' => [:border, :tab_fields, :time_short, :spinner],
226
+ 'c_date_time_drop_down' => [:border, :tab_fields, :drop_down],
227
+ 'c_date_drop_down' => [:border, :tab_fields, :drop_down, :date_short],
228
+ 'c_time_drop_down' => [:border, :tab_fields, :drop_down, :time_short],
229
+ ```
230
+
231
+ ### Data-Binding and Observers:
232
+
233
+ The `selection` property provides access to the value selected by the user. It can be hooked with basic data-binding to a model property. Additionaly observers may be attached too, such as `on_widget_selected` and `on_key_pressed`.
234
+
235
+ Example:
72
236
 
73
237
  ```ruby
74
238
  # ...
75
239
  composite {
76
240
  # ...
77
- @start_at = c_date_time(CDT::BORDER | CDT::COMPACT | CDT::DROP_DOWN | CDT::DATE_LONG) {
241
+ @start_at = c_date_time(:border, :drop_down, :date_long) {
78
242
  # ...
79
243
  selection bind(@task, :start_at)
80
244
  on_key_pressed { |event|
@@ -85,9 +249,13 @@ Here is the Nebula CDateTime Widget [Javadoc API page](https://www.eclipse.org/n
85
249
  # ...
86
250
  ```
87
251
 
88
- ![Nebula CDateTime Example](glimmer-cw-cdatetime-nebula-example.png)
252
+ ![Nebula CDateTime Example](images/glimmer-cw-cdatetime-nebula-example.png)
253
+
254
+ ### Table Editing
89
255
 
90
- ### Example of using `c_date_time` as a `table` / `table_column` editor:
256
+ `c_date_time` can be used as a `table` / `table_column` editor.
257
+
258
+ Example:
91
259
 
92
260
  ```ruby
93
261
  # ...
@@ -96,12 +264,12 @@ Here is the Nebula CDateTime Widget [Javadoc API page](https://www.eclipse.org/n
96
264
  table_column {
97
265
  text 'Start Date'
98
266
  width CONFIG[:table_column_width_hint]
99
- editor :c_date_time, CDT::BORDER | CDT::COMPACT | CDT::DROP_DOWN | CDT::DATE_LONG, property: :start_at
267
+ editor :c_date_time, cdt(:border, :drop_down, :date_long), property: :start_at
100
268
  }
101
269
  table_column {
102
270
  text 'End Date'
103
271
  width CONFIG[:table_column_width_hint]
104
- editor :c_date_time, CDT::BORDER | CDT::COMPACT | CDT::DROP_DOWN | CDT::DATE_LONG, property: :end_at
272
+ editor :c_date_time, cdt(:border, :drop_down, :date_long), property: :end_at
105
273
  }
106
274
  # ... other table_column declarations
107
275
  items bind(Task, :list), column_properties(:project_name, :task_type, :name, :start_date, :end_date, :duration, :priority)
@@ -110,12 +278,44 @@ Here is the Nebula CDateTime Widget [Javadoc API page](https://www.eclipse.org/n
110
278
  # ...
111
279
  ```
112
280
 
113
- ![Nebula CDateTime Example](glimmer-cw-cdatetime-nebula-example-table-editor.png)
281
+ ![Nebula CDateTime Example](images/glimmer-cw-cdatetime-nebula-example-table-editor.png)
282
+
283
+ ## API
284
+
285
+ You may check out the Nebula CDateTime Widget [Javadoc API](https://www.eclipse.org/nebula/releases/latest/javadoc/org/eclipse/nebula/widgets/cdatetime/CDateTime.html).
286
+
287
+ ### Glimmer Custom API
288
+
289
+ Glimmer adds a few extra API methods to CDateTime from Nebula.
290
+
291
+ #### `toggle_open`
292
+
293
+ Programmatically toggle date/time dropdown as open (simpler than directly calling `.swt_widget.set_open` in certain circumstances)
294
+
295
+ #### `text_widget_proxy`
296
+
297
+ Provides access to the inner text widget to allow programmatic adding of obesrvers and/or data-binding.
298
+
299
+ Example:
300
+
301
+ ```
302
+ c_time { |proxy|
303
+ proxy.text_widget_proxy.content {
304
+ on_swt_mouseup { |event|
305
+ proxy.toggle_open
306
+ }
307
+ }
308
+ }
309
+ ```
310
+
311
+
312
+ ## TODO
313
+
314
+ [TODO.md](TODO.md)
114
315
 
115
316
  ## Change Log
116
317
 
117
- - 1.4.0.1: Prevent table editor from saving upon traversing months in drop down Calendar
118
- - 1.4.0.0: Initial version
318
+ [CHANGELOG.md](CHANGELOG.md)
119
319
 
120
320
  ## Contributing to glimmer-cw-cdatetime-nebula
121
321
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.0.1
1
+ 1.4.0.2.0
@@ -1,3 +1,24 @@
1
+ # Copyright (c) 2020 - Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
1
22
  $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
2
23
  $LOAD_PATH.unshift(File.expand_path('../..', __FILE__))
3
24
 
@@ -11,4 +32,47 @@ Glimmer::Config.import_swt_packages += [
11
32
  'org.eclipse.nebula.widgets.cdatetime',
12
33
  ]
13
34
 
35
+ require 'glimmer-cw-cdatetime-nebula/ext/glimmer/dsl/swt/cdt_expression'
36
+ require 'glimmer-cw-cdatetime-nebula/ext/glimmer/swt/c_date_time_proxy'
14
37
  require 'views/nebula/c_date_time'
38
+
39
+ Glimmer::SWT::WidgetProxy::DEFAULT_STYLES.merge!(
40
+ 'c_date_time' => [:border, :tab_fields, :simple],
41
+ 'c_date' => [:border, :tab_fields, :date_short, :simple],
42
+ 'c_time' => [:border, :tab_fields, :time_short, :simple],
43
+ 'c_date_time_compact' => [:border, :tab_fields, :compact],
44
+ 'c_date_compact' => [:border, :tab_fields, :date_short, :compact],
45
+ 'c_time_compact' => [:border, :tab_fields, :time_short, :compact],
46
+ 'c_date_time_spinner' => [:border, :tab_fields, :spinner],
47
+ 'c_date_spinner' => [:border, :tab_fields, :date_short, :spinner],
48
+ 'c_time_spinner' => [:border, :tab_fields, :time_short, :spinner],
49
+ 'c_date_time_drop_down' => [:border, :tab_fields, :drop_down],
50
+ 'c_date_drop_down' => [:border, :tab_fields, :drop_down, :date_short],
51
+ 'c_time_drop_down' => [:border, :tab_fields, :drop_down, :time_short],
52
+ )
53
+
54
+ Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_date_time'] = Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_date_time_compact'] = Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_date_time_spinner'] = Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_date_time_drop_down'] = lambda do |widget|
55
+ widget.pattern = 'MM/dd/yyyy hh:mm a'
56
+ end
57
+ Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_date'] = Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_date_compact'] = Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_date_spinner'] = Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_date_drop_down'] = lambda do |widget|
58
+ widget.pattern = 'MM/dd/yyyy'
59
+ end
60
+ Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_time'] = Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_time_compact'] = Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_time_spinner'] = Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['c_time_drop_down'] = lambda do |widget|
61
+ widget.pattern = 'hh:mm a'
62
+ end
63
+
64
+ Glimmer::SWT::WidgetProxy::KEYWORD_ALIASES.merge!(
65
+ 'c_date' => 'c_date_time',
66
+ 'c_time' => 'c_date_time',
67
+ 'c_date_time_compact' => 'c_date_time',
68
+ 'c_date_compact' => 'c_date_time',
69
+ 'c_time_compact' => 'c_date_time',
70
+ 'c_date_time_spinner' => 'c_date_time',
71
+ 'c_date_spinner' => 'c_date_time',
72
+ 'c_time_spinner' => 'c_date_time',
73
+ 'c_date_time_drop_down' => 'c_date_time',
74
+ 'c_date_drop_down' => 'c_date_time',
75
+ 'c_time_drop_down' => 'c_date_time',
76
+ )
77
+
78
+ Glimmer::Config::SAMPLE_DIRECTORIES << File.expand_path('../../samples/nebula', __FILE__)
@@ -0,0 +1,23 @@
1
+ require 'glimmer/dsl/static_expression'
2
+ require 'glimmer-cw-cdatetime-nebula/ext/glimmer/swt/cdt_proxy'
3
+
4
+ module Glimmer
5
+ module DSL
6
+ module SWT
7
+ # Extends Glimmer DSL to easily build CDT constant values with `cdt(arg)`
8
+ #
9
+ # Named CdtExpression (not CDTExpression) so that the DSL engine
10
+ # discovers quickly by convention
11
+ class CdtExpression < StaticExpression
12
+ def can_interpret?(parent, keyword, *args, &block)
13
+ block.nil? &&
14
+ args.size > 0
15
+ end
16
+
17
+ def interpret(parent, keyword, *args, &block)
18
+ Glimmer::SWT::CDTProxy[*args]
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,78 @@
1
+ # Copyright (c) 2020 - Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ module Glimmer
23
+ module SWT
24
+ # This modules just configures Glimmer to work with Nebula CDateTime
25
+ # Since it is wrapping an existing SWT widget with the same name,
26
+ # it is not implemented as a typical "Glimmer Custom Widget", yet
27
+ # just a Glimmer widget proxy that extends Glimmer::SWT::WidgetProxy
28
+ class CDateTimeProxy < Glimmer::SWT::WidgetProxy
29
+ def text_widget_proxy
30
+ Glimmer::SWT::WidgetProxy.new(swt_widget: swt_widget.text_widget.control)
31
+ end
32
+
33
+ def toggle_open
34
+ swt_widget.set_open(!swt_widget.is_open)
35
+ end
36
+
37
+ private
38
+
39
+ def has_style?(style)
40
+ begin
41
+ comparison = CDTProxy[style]
42
+ rescue
43
+ begin
44
+ comparison = SWTProxy[style]
45
+ rescue
46
+ comparison = DNDProxy[style]
47
+ end
48
+ end
49
+ (@swt_widget.style & comparison) == comparison
50
+ end
51
+
52
+ def default_style(underscored_widget_name)
53
+ styles = DEFAULT_STYLES[underscored_widget_name] || [:none]
54
+ CDTProxy[styles] rescue SWTProxy[styles] rescue DNDProxy[styles]
55
+ end
56
+
57
+ def style(underscored_widget_name, styles)
58
+ styles = [styles].flatten.compact
59
+ if styles.empty?
60
+ default_style(underscored_widget_name)
61
+ else
62
+ begin
63
+ CDTProxy[*styles]
64
+ rescue
65
+ begin
66
+ SWTProxy[*styles]
67
+ rescue
68
+ DNDProxy[*styles]
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1,55 @@
1
+ # Copyright (c) 2020 - Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/swt/style_constantizable'
23
+
24
+ module Glimmer
25
+ module SWT
26
+ # Proxy for org.eclipse.nebula.widgets.cdatetime.CDT
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class CDTProxy
30
+ include Glimmer::SWT::StyleConstantizable
31
+
32
+ class << self
33
+ JAVA_IMPORT = 'org.eclipse.nebula.widgets.cdatetime.CDT'
34
+
35
+ java_import JAVA_IMPORT
36
+
37
+ def constant_java_import
38
+ JAVA_IMPORT
39
+ end
40
+
41
+ def constant_source_class
42
+ CDT
43
+ end
44
+
45
+ def constant_value_none
46
+ CDT::NONE
47
+ end
48
+
49
+ def extra_styles
50
+ {}
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -6,7 +6,7 @@ module Nebula
6
6
  Glimmer::SWT::TableProxy.editors[:c_date_time] ||= {
7
7
  widget_value_property: :selection,
8
8
  editor_gui: lambda do |args, model, property, table_proxy|
9
- args << CDT::DROP_DOWN if args.empty?
9
+ args << cdt(:drop_down) if args.empty?
10
10
  table_editor_widget_proxy = c_date_time(*args) {
11
11
  table_proxy.table_editor.minimumHeight = 20
12
12
  selection model.send(property)
@@ -0,0 +1,157 @@
1
+ # Copyright (c) 2020 - Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require_relative '../../lib/glimmer-cw-cdatetime-nebula'
23
+
24
+ class CDateTimeGallery
25
+ include Glimmer
26
+
27
+ def open
28
+ shell {
29
+ grid_layout(4, false) {
30
+ vertical_spacing 20
31
+ }
32
+ text 'Nebula CDateTime Glimmer Custom Widget Gallery'
33
+
34
+ label {
35
+ layout_data(:center, :center, true, false) {
36
+ horizontal_span 4
37
+ }
38
+ text 'Nebula CDateTime Glimmer Custom Widget Gallery'
39
+ font height: 24, style: :bold
40
+ }
41
+
42
+ tab_folder {
43
+ tab_item {
44
+ grid_layout 2, false
45
+ text 'Plain'
46
+
47
+ label {
48
+ text 'c_date_time'
49
+ font name: 'Consolas', height: 14
50
+ }
51
+ c_date_time
52
+
53
+ label {
54
+ text 'c_date'
55
+ font name: 'Consolas', height: 14
56
+ }
57
+ c_date
58
+
59
+ label {
60
+ text 'c_time'
61
+ font name: 'Consolas', height: 14
62
+ }
63
+ c_time
64
+ }
65
+
66
+ tab_item {
67
+ grid_layout 2, false
68
+ text 'Drop Down'
69
+
70
+ label {
71
+ text 'c_date_time_drop_down'
72
+ font name: 'Consolas', height: 14
73
+ }
74
+ c_date_time_drop_down {
75
+ layout_data(:fill, :center, true, true)
76
+ }
77
+
78
+ label {
79
+ text 'c_date_drop_down'
80
+ font name: 'Consolas', height: 14
81
+ }
82
+ c_date_drop_down {
83
+ layout_data(:fill, :center, true, true)
84
+ }
85
+
86
+ label {
87
+ text 'c_time_drop_down'
88
+ font name: 'Consolas', height: 14
89
+ }
90
+ c_time_drop_down {
91
+ layout_data(:fill, :center, true, true)
92
+ }
93
+ }
94
+
95
+ tab_item {
96
+ grid_layout 2, false
97
+ text 'Spinner'
98
+
99
+ label {
100
+ text 'c_date_time_spinner'
101
+ font name: 'Consolas', height: 14
102
+ }
103
+ c_date_time_spinner {
104
+ layout_data(:fill, :center, true, true)
105
+ }
106
+
107
+ label {
108
+ text 'c_date_spinner'
109
+ font name: 'Consolas', height: 14
110
+ }
111
+ c_date_spinner {
112
+ layout_data(:fill, :center, true, true)
113
+ }
114
+
115
+ label {
116
+ text 'c_time_spinner'
117
+ font name: 'Consolas', height: 14
118
+ }
119
+ c_time_spinner {
120
+ layout_data(:fill, :center, true, true)
121
+ }
122
+ }
123
+
124
+ tab_item {
125
+ grid_layout 2, false
126
+ text 'Compact'
127
+
128
+ label {
129
+ text 'c_date_time_compact'
130
+ font name: 'Consolas', height: 14
131
+ }
132
+ c_date_time_compact {
133
+ layout_data(:fill, :center, true, true)
134
+ }
135
+
136
+ label {
137
+ text 'c_date_compact'
138
+ font name: 'Consolas', height: 14
139
+ }
140
+ c_date_compact {
141
+ layout_data(:fill, :center, true, true)
142
+ }
143
+
144
+ label {
145
+ text 'c_time_compact'
146
+ font name: 'Consolas', height: 14
147
+ }
148
+ c_time_compact {
149
+ layout_data(:fill, :center, true, true)
150
+ }
151
+ }
152
+ }
153
+ }.open
154
+ end
155
+ end
156
+
157
+ CDateTimeGallery.new.open
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-cw-cdatetime-nebula
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0.1
4
+ version: 1.4.0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-08 00:00:00.000000000 Z
11
+ date: 2020-09-17 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.3.1
18
+ version: 0.6.8
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 2.0.0
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.3.1
29
+ version: 0.6.8
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.0.0
@@ -87,7 +87,8 @@ dependencies:
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  description: Nebula CDateTime Widget - Glimmer Custom Widget - A Date and Time selection
90
- widget that can be used in a textual, graphical, or combo mode.
90
+ widget that can be used in a plain (graphical), dropdown, spinner, or compact text
91
+ style.
91
92
  email: andy.am@gmail.com
92
93
  executables: []
93
94
  extensions: []
@@ -99,7 +100,11 @@ files:
99
100
  - README.md
100
101
  - VERSION
101
102
  - lib/glimmer-cw-cdatetime-nebula.rb
103
+ - lib/glimmer-cw-cdatetime-nebula/ext/glimmer/dsl/swt/cdt_expression.rb
104
+ - lib/glimmer-cw-cdatetime-nebula/ext/glimmer/swt/c_date_time_proxy.rb
105
+ - lib/glimmer-cw-cdatetime-nebula/ext/glimmer/swt/cdt_proxy.rb
102
106
  - lib/views/nebula/c_date_time.rb
107
+ - samples/nebula/c_date_time_gallery.rb
103
108
  - vendor/nebula/org.eclipse.nebula.cwt_1.1.0.jar
104
109
  - vendor/nebula/org.eclipse.nebula.widgets.cdatetime_1.4.0.jar
105
110
  homepage: http://github.com/AndyObtiva/glimmer-cw-cdatetime-nebula