README.md in glimmer-cw-cdatetime-nebula-1.5.0.1.0 vs README.md in glimmer-cw-cdatetime-nebula-1.5.0.2.0

- old
+ new

@@ -1,27 +1,34 @@ -# Nebula CDateTime Widget 1.5.0.1.0 +# Nebula CDateTime Widget 1.5.0.2.0 ## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-swt/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer Custom Widget](https://github.com/AndyObtiva/glimmer-dsl-swt#custom-widget-gem) [![Gem Version](https://badge.fury.io/rb/glimmer-cw-cdatetime-nebula.svg)](http://badge.fury.io/rb/glimmer-cw-cdatetime-nebula) [<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) 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 simple, dropdown, spinner, or compact style. Packaged as a [Glimmer Custom Widget](https://github.com/AndyObtiva/glimmer-dsl-swt#custom-widget-gem) to provide date/time selection via a combo/dropdown-style widget in [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) using the `c_date_time` [Glimmer DSL](https://github.com/AndyObtiva/glimmer-dsl-swt#glimmer-gui-dsl-syntax) keyword. +Now, also supports [Glimmer DSL for Opal](#glimmer-dsl-for-opal) Auto-Webifier of Desktop Apps via Rails/Opal. + [glimmer-cw-cdatetime-nebula](https://rubygems.org/gems/glimmer-cw-cdatetime-nebula) 1.5.0.x.y gem versions map to Nebula CDateTime Widget version 1.5.0 (which comes with [Nebula 2.4.2](https://www.eclipse.org/nebula/releases/2.4.2/index.php)) ## Table of contents -- [Nebula CDateTime Widget 1.5.0.1.0](#nebula-cdatetime-widget-15010) +- [Nebula CDateTime Widget 1.5.0.2.0](#nebula-cdatetime-widget-15020) - [Pre-requisites](#pre-requisites) - [Setup](#setup) - - [Glimmer Application](#glimmer-application) - - [Glimmer Custom Shell or Glimmer Custom Widget](#glimmer-custom-shell-or-glimmer-custom-widget) - - [Java Imports](#java-imports) + - [Glimmer DSL for SWT](#glimmer-dsl-for-swt) + - [Glimmer Application](#glimmer-application) + - [Glimmer Custom Shell or Glimmer Custom Widget](#glimmer-custom-shell-or-glimmer-custom-widget) + - [Java Imports](#java-imports) + - [Glimmer DSL for Opal](#glimmer-dsl-for-opal) + - [Setup](#setup) - [Instructions](#instructions) - [Sample](#sample) + - [Glimmer DSL for SWT Sample](#glimmer-dsl-for-swt-sample) + - [Glimmer DSL for Opal Sample](#glimmer-dsl-for-opal-sample) - [Simple Style](#simple-style) - [`c_date_time`](#cdatetime) - [`c_date`](#cdate) - [`c_time`](#ctime) - [Drop Down Style](#drop-down-style) @@ -48,52 +55,90 @@ - [Contributing to glimmer-cw-cdatetime-nebula](#contributing-to-glimmer-cw-cdatetime-nebula) - [Copyright](#copyright) ## Pre-requisites -- [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) application, [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) custom shell, or another [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) custom widget +- [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) application, [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) custom shell, or another [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) custom widget - JRuby version required by [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) - Java version required by [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) +For [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) auto-webification, this is also required: + +- [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) Rails application +- [Clocklet](https://github.com/luncheon/clocklet) (included in gem) + ## Setup Versions follow this convention: - First 3 numbers map to the official Nebula CDateTime library version (e.g. 1.5.0) - Last 2 numbers map to minor and patch versions for Glimmer Custom Widget wrapper -### Glimmer Application +### Glimmer DSL for SWT +#### Glimmer Application + Add the following to a [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) application `Gemfile`: ```ruby -gem 'glimmer-cw-cdatetime-nebula', '1.5.0.1.0' +gem 'glimmer-cw-cdatetime-nebula', '~> 1.5.0.2.0' ``` Run: ``` jruby -S bundle ``` (or just `bundle` if using [RVM) -### Glimmer Custom Shell or Glimmer Custom Widget +#### Glimmer Custom Shell or Glimmer Custom Widget When reusing in a [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) 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: ```ruby require 'glimmer-dsl-swt' require 'glimmer-cw-cdatetime-nebula' # ... more require statements follow ``` -### Java Imports +#### Java Imports Requiring the gem automatically configures java imports in [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) for auto import via [JRuby](https://www.jruby.org/) `include_package` on first use: - `org.eclipse.nebula.cwt` - `org.eclipse.nebula.widgets.cdatetime` +### Glimmer DSL for Opal + +The [glimmer-cw-cdatetime-nebula](https://rubygems.org/gems/glimmer-cw-cdatetime-nebula) gem is a Rails Engine gem that includes assets and supports [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal). + +#### Setup + +Please follow the following steps to setup assuming you have a pre-setup [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) Rails app. + +Add the following to `Gemfile` after `glimmer-dsl-opal` and other `glimer-dsl-*` gems: + +```ruby +gem 'glimmer-cw-cdatetime-nebula', '~> 1.5.0.2.0' +``` + +Edit `app/views/layouts/application.html.erb` and add the following below other `stylesheet_link_tag` declarations: + +```erb +<%= stylesheet_link_tag 'glimmer_cw_cdatetime_nebula/glimmer_cw_cdatetime_nebula', media: 'all', 'data-turbolinks-track': 'reload' %> +``` + +That's it! Now, you can use the following keywords: +- `c_date` +- `c_time` +- `c_date_drop_down` +- `c_time_drop_down` +- `c_time_compact` + +Here is a sample Rails app that has everything configured (you just have to edit `app/assets/javascripts/application.rb` to enable the desired sample): + +https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails5-app + ## Instructions 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-dsl-swt#glimmer-gui-dsl-syntax) as well as other alias keywords (e.g. drop down style, spinner style, and compact style) as explained below. The `c_date_time` keyword optionally takes [`CDT`](#cdt) style bits as arguments. When not specified, [smart defaults](https://github.com/AndyObtiva/glimmer-cw-cdatetime-nebula#cdt-style-arguments) are used instead. @@ -106,10 +151,12 @@ Further instructions may be found at the [Nebula CDateTime Widget homepage](https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php). ### Sample +#### Glimmer DSL for SWT Sample + Please run the following command to launch the [Nebula CDateTime Glimmer Custom Widget Gallery](samples/nebula/c_date_time_gallery.rb) app: ``` glimmer sample:run[c_date_time_gallery] ``` @@ -121,14 +168,14 @@ class CDateTimeGallery include Glimmer def open - shell { + shell { grid_layout(4, false) { vertical_spacing 20 - } + } text 'Nebula CDateTime Glimmer Custom Widget Gallery' label { layout_data(:center, :center, true, false) { horizontal_span 4 @@ -137,11 +184,11 @@ font height: 24, style: :bold } tab_folder { tab_item { - grid_layout 2, false + grid_layout 2, false text 'Simple' label { text 'c_date_time' font name: 'Consolas', height: 14 @@ -189,11 +236,11 @@ layout_data(:fill, :center, true, true) } } tab_item { - grid_layout 2, false + grid_layout 2, false text 'Spinner' label { text 'c_date_time_spinner' font name: 'Consolas', height: 14 @@ -218,11 +265,11 @@ layout_data(:fill, :center, true, true) } } tab_item { - grid_layout 2, false + grid_layout 2, false text 'Compact' label { text 'c_date_time_compact' font name: 'Consolas', height: 14 @@ -244,19 +291,41 @@ font name: 'Consolas', height: 14 } c_time_compact { layout_data(:fill, :center, true, true) } - } + } } - }.open - end + }.open + end end CDateTimeGallery.new.open ``` +#### Glimmer DSL for Opal Sample + +The same Glimmer DSL for SWT sample runs in Glimmer DSL for Opal unchanged, albeit with partial support at the moment. + +Open a `Document.ready?` block in `app/assets/javascripts/application.rb` and add inside it the Glimmer GUI DSL code above or a require statement as done below. + +```ruby +require 'glimmer-dsl-opal' + +Document.ready? do + require 'samples/nebula/c_date_time_gallery.rb' +end +``` + +Run: + +`rails s` + +Visit: 'http://localhost:3000' + +![simple screenshot](images/glimmer-cw-cdatetime-nebula-opal-simple.png) + ### Simple Style Simple style is the default style when using `c_date_time`, `c_date`, and `c_time` keywords. It displays a graphical calendar/clock. `CDT::SIMPLE` style is applied by default but may be overriden by manually passing arguments to the keywords. @@ -387,11 +456,11 @@ 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`. Example: ```ruby -# ... +# ... composite { # ... @start_at = c_date_time(:border, :drop_down, :date_long) { # ... selection bind(@task, :start_at) @@ -473,10 +542,9 @@ proxy.toggle_open } } } ``` - ## TODO [TODO.md](TODO.md)