Skip to content

Commit

Permalink
More changes regarding sash_form.weights/samples:
Browse files Browse the repository at this point in the history
- Replace dependency on tty-markdown gem with dependency on rouge gem instead
- Remove rake tasks `sample:list`, `sample:code` and `sample:run`
- Add rake task `samples` to point to the new Glimmer Meta-Sample
- Have meta-sample load samples from gems
- Covered sash_form.weights with rspec tests
  • Loading branch information
AndyObtiva committed Oct 21, 2020
1 parent f9b8d1b commit 8d8bed7
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 164 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

### 4.17.4.0

- Glimmer sample app to launch samples (sample of samples meta-sample)
- Syntax Color Highlighting in meta-sample
- Make sash_form weights accept splat array elements (not wrapped in [])
- Make sash_form weights not get set till the closing of the sash_form (to allow putting it above content instead of below as originally required by SWT)
- Replace dependency on tty-markdown gem with dependency on rouge gem instead
- Remove rake tasks `sample:list`, `sample:code` and `sample:run`
- Add rake task `samples` to point to the new Glimmer Meta-Sample
- Have meta-sample load samples from gems

### 4.17.3.0

- `glimmer scaffold:desktopify[appname,website]` Mac
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ gem 'logging', '>= 2.3.0', '< 3.0.0'
gem 'os', '>= 1.0.0', '< 2.0.0'
gem 'rake', '>= 10.1.0', '< 14.0.0'
gem 'text-table', '>= 1.2.4', '< 2.0.0'
gem 'tty-markdown', '>= 0.6.0', '< 2.0.0'
gem 'rouge', '>= 3.23.0', '< 4.0.0'

group :development do
gem 'juwelier', '>= 2.4.9', '< 3.0.0'
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [<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 4.17.3.0
# [<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 4.17.4.0
## JRuby Desktop Development GUI Library
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
Expand Down Expand Up @@ -431,7 +431,7 @@ jgem install glimmer-dsl-swt

Or this command if you want a specific version:
```
jgem install glimmer-dsl-swt -v 4.17.3.0
jgem install glimmer-dsl-swt -v 4.17.4.0
```

Note: Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT.
Expand Down Expand Up @@ -508,7 +508,7 @@ bin/glimmer sample:run[hello_world]
Below are the full usage instructions that come up when running `glimmer` without args.

```
Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.3.0
Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.4.0
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
Expand Down Expand Up @@ -625,7 +625,7 @@ This will run the hello_tab sample and output its code:
```
$ glimmer sample:run[hello_tab]
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.3.0/samples/hello/hello_tab.rb
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.4.0/samples/hello/hello_tab.rb
class HelloTab
include Glimmer
Expand Down Expand Up @@ -670,7 +670,7 @@ Example:
```
$ glimmer sample:code[tic_tac_toe]
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.3.0/samples/elaborate/tic_tac_toe.rb
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.4.0/samples/elaborate/tic_tac_toe.rb
require_relative "tic_tac_toe/board"
Expand Down Expand Up @@ -731,7 +731,7 @@ TicTacToe.new.open
# # #
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.3.0/samples/elaborate/tic_tac_toe/cell.rb
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.4.0/samples/elaborate/tic_tac_toe/cell.rb
class TicTacToe
class Cell
Expand Down Expand Up @@ -764,7 +764,7 @@ end
# # #
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.3.0/samples/elaborate/tic_tac_toe/board.rb
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.4.0/samples/elaborate/tic_tac_toe/board.rb
require_relative 'cell'
Expand Down Expand Up @@ -1302,8 +1302,8 @@ Output:
Name Gem Version Author Description
Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
Opal glimmer-dsl-opal 0.3.0 AndyMaleh Glimmer DSL for Opal
Swt glimmer-dsl-swt 4.17.3.0 AndyMaleh Glimmer DSL for SWT
Opal glimmer-dsl-opal 0.4.0 AndyMaleh Glimmer DSL for Opal
Swt glimmer-dsl-swt 4.17.4.0 AndyMaleh Glimmer DSL for SWT
Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
```
Expand Down
11 changes: 5 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ Here is a list of tasks to do (moved to [CHANGELOG.md](CHANGELOG.md) once done).

## Next

- Build a mini Glimmer app to launch samples (sample of samples meta-sample)
- Have meta-sample load samples from gems
- Syntax Color Highlighting in metasample
- Make sash_form weights accept splat array elements (not wrapped in [])

- Document sash_form in README
- Update documentation with regards to how to run samples (removing references to sample:run)

## Soon

Expand All @@ -21,6 +18,9 @@ Here is a list of tasks to do (moved to [CHANGELOG.md](CHANGELOG.md) once done).
- Support glimmer list:gems (listing all types of gems together)
- glimmer webify task, which generates a Glimmer DSL for Opal Rails app for a desktop app and publishes it on Heroku
- Make glimmer meta samples editable for experimentation before launching a sample
- Make code_text custom widget support multiple languages
- Make code_text custom widget auto-detect current language
- Remove dependencies on gems that are only needed for Glimmer tasks (loading them at the time of running those tasks only)

- Log exceptions that occur in event listener blocks
# - Log exceptions that happen in CustomWidget body, before_body, and after_body blocks
Expand Down Expand Up @@ -203,7 +203,6 @@ items <=> binding {
- Add `widget` keyword to build proxies for swt widgets without directly using Glimmer::SWT::WidgetProxy
- Look into modularizing the menu and prefrences into separate components for a scaffolded app/custom-shell
- Consider adding sash_form children style for having a fixed size when resizing, or provide a flexible alternative via sash widget
- Make sash_form weights not execute till the closing of the sash_form (to allow putting it above content instead of below as required by Java)
- Speed up glimmer command with CRuby compatibility via jruby-jars gem
- Build a TUI for browsing/running internal gem samples
- Syntax-highlight sample code when output with `glimmer sample:code` command
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.17.3.0
4.17.4.0
1 change: 1 addition & 0 deletions lib/glimmer/dsl/swt/widget_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ def add_content(parent, &block)
require 'glimmer/swt/tree_proxy'
require 'glimmer/swt/table_proxy'
require 'glimmer/swt/table_column_proxy'
require 'glimmer/swt/sash_form_proxy'
23 changes: 3 additions & 20 deletions lib/glimmer/rake_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,9 @@ module RakeTask
end
end

namespace :sample do
task :requires do
require_relative 'rake_task/sample'
end

desc 'Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples.'
task :run, [:name] => [:requires] do |t, args|
Glimmer::RakeTask::Sample.run(args[:name])
end

desc 'Lists Glimmer internal samples [included in gem]. Filters by query if specified (query is optional)'
task :list, [:query] => [:requires] do |t, args|
Glimmer::RakeTask::Sample.list(args[:query])
end

desc 'Outputs code for a Glimmer internal sample [included in gem] (name is required)'
task :code, [:name] => [:requires] do |t, args|
Glimmer::RakeTask::Sample.code(args[:name])
end

desc 'Brings up the Glimmer Meta-Sample app to allow browsing, running, and viewing code of Glimmer samples (including samples in installed Glimmer gems)'
task :samples do
Glimmer::Launcher.new([File.expand_path('../../../samples/meta_sample.rb', __FILE__)]).launch
end

namespace :package do
Expand Down
115 changes: 0 additions & 115 deletions lib/glimmer/rake_task/sample.rb

This file was deleted.

7 changes: 6 additions & 1 deletion lib/glimmer/swt/custom/code_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
module Glimmer
module SWT
module Custom
# CodeText is a customization of StyledText with support for Ruby Syntax Highlighting
class CodeText
include Glimmer::UI::CustomWidget
extend Glimmer

SYNTAX_COLOR_MAP = {
Builtin: rgb(215,58,73),
Expand All @@ -24,7 +26,10 @@ class CodeText
Single: rgb(106,115,125), # Also, Comments
Symbol: color(:dark_green),
Text: rgb(75, 75, 75),
}
}

# TODO support `option :language`
# TODO support auto language detection

def text=(value)
swt_widget&.text = value
Expand Down
2 changes: 1 addition & 1 deletion lib/glimmer/swt/message_box_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

module Glimmer
module SWT
# Proxy for org.eclipse.swt.widgets.Shell
# Proxy for org.eclipse.swt.widgets.MessageBox
#
# Follows the Proxy Design Pattern
class MessageBoxProxy
Expand Down
53 changes: 53 additions & 0 deletions lib/glimmer/swt/sash_form_proxy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright (c) 2007-2020 Andy Maleh
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

require 'glimmer/swt/widget_proxy'

module Glimmer
module SWT
# Proxy for org.eclipse.swt.custom.SashForm
#
# Follows the Proxy Design Pattern
class SashFormProxy < WidgetProxy
def post_add_content
swt_widget.setWeights(@weights) unless @weights.nil?
end

def set_attribute(attribute_name, *args)
if attribute_name.to_s == "weights"
@weights = args
@weights = @weights.first if @weights.first.is_a?(Array)
else
super(attribute_name, *args)
end
end

def get_attribute(attribute_name)
if attribute_name.to_s == "weights"
swt_widget.getWeights.to_a
else
super(attribute_name)
end
end

end
end
end
7 changes: 0 additions & 7 deletions lib/glimmer/swt/widget_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -622,13 +622,6 @@ def widget_custom_attribute_mapping
getter: {name: 'getSelectionCount'},
setter: {name: 'setSelection', invoker: lambda { |widget, args| @swt_widget.setSelection(@swt_widget.getCaretPosition, @swt_widget.getCaretPosition + args.first) if args.first }},
},
'weights' => {
getter: {name: 'getWeights'},
setter: {name: 'setWeights', invoker: lambda do |widget, args|
args = args.first if args.first.is_a?(Array) && args.size == 1
@swt_widget.setWeights(args)
end},
},
}
end

Expand Down
Loading

0 comments on commit 8d8bed7

Please sign in to comment.