reactive_view_wx 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +3 -0
- data/MIT-LICENSE +21 -0
- data/Manifest.txt +37 -0
- data/README.txt +19 -0
- data/Rakefile +16 -0
- data/lib/action_view_init.rb +13 -0
- data/lib/base.rb +59 -0
- data/lib/binder.rb +20 -0
- data/lib/helpers/model_edit_ctrl_class.rb +124 -0
- data/lib/helpers/model_list_ctrl_class.rb +82 -0
- data/lib/helpers/model_main_frame_class.rb +132 -0
- data/lib/helpers/model_show_ctrl_class.rb +35 -0
- data/lib/reactive_view_wx.rb +22 -0
- data/lib/request.rb +14 -0
- data/lib/template.rb +114 -0
- data/lib/version.rb +13 -0
- data/lib/xrc_pepper.rb +253 -0
- data/reactive_generators/application_view/USAGE +7 -0
- data/reactive_generators/application_view/application_view_generator.rb +49 -0
- data/reactive_generators/application_view/templates/application_helper.rb +40 -0
- data/reactive_generators/application_view/templates/application_layout.rb +2 -0
- data/reactive_generators/application_view/templates/application_view.rb +9 -0
- data/reactive_generators/application_view/templates/assets/delete16.png +0 -0
- data/reactive_generators/application_view/templates/assets/edit16.png +0 -0
- data/reactive_generators/application_view/templates/assets/show16.png +0 -0
- data/reactive_generators/application_view/templates/record_toolbar.rb +46 -0
- data/reactive_generators/view/USAGE +16 -0
- data/reactive_generators/view/templates/create.rb +1 -0
- data/reactive_generators/view/templates/delete.rb +3 -0
- data/reactive_generators/view/templates/destroy.rb +0 -0
- data/reactive_generators/view/templates/edit.rb +8 -0
- data/reactive_generators/view/templates/index.rb +4 -0
- data/reactive_generators/view/templates/layout.rb +2 -0
- data/reactive_generators/view/templates/new.rb +8 -0
- data/reactive_generators/view/templates/show.rb +4 -0
- data/reactive_generators/view/templates/update.rb +1 -0
- data/reactive_generators/view/view_generator.rb +69 -0
- metadata +146 -0
@@ -0,0 +1,7 @@
|
|
1
|
+
Description:
|
2
|
+
Creates the initial application view and some usefull helpers.
|
3
|
+
This generator is automatically called when you generate your application
|
4
|
+
and pass a view provider. If you didn't, use it directly.
|
5
|
+
|
6
|
+
Example:
|
7
|
+
`./script/generate application_view --title="My Sales"`
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class ApplicationViewGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
default_options :author => nil
|
4
|
+
|
5
|
+
attr_reader :title, :app_name
|
6
|
+
|
7
|
+
def initialize(runtime_args, runtime_options = {})
|
8
|
+
super
|
9
|
+
@destination_root = args.shift unless @destination_root
|
10
|
+
extract_options
|
11
|
+
end
|
12
|
+
|
13
|
+
def manifest
|
14
|
+
record do |m|
|
15
|
+
# Ensure appropriate folder(s) exists
|
16
|
+
m.directory 'app/views/layouts'
|
17
|
+
m.directory 'app/views/application'
|
18
|
+
m.directory 'app/helpers'
|
19
|
+
|
20
|
+
m.template "application_view.rb", "app/views/application.rb"
|
21
|
+
m.template "application_layout.rb", "app/views/layouts/application.rb"
|
22
|
+
m.template "record_toolbar.rb", "app/views/application/record_toolbar.rb"
|
23
|
+
m.template "application_helper.rb", "app/helpers/application_helper.rb"
|
24
|
+
|
25
|
+
m.file_copy_each %w( show16.png edit16.png delete16.png ), "assets"
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
def banner
|
32
|
+
"Usage: #{$0} #{spec.name} [options]"
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_options!(opts)
|
36
|
+
opts.separator ''
|
37
|
+
opts.separator 'Options:'
|
38
|
+
opts.on("-n", "--name=\"App name\"", "Specifies the application name. Used in message boxes.") { |v| options[:app_name] = v }
|
39
|
+
opts.on("--title=\"Window title\"", "Specifies the main window title.") { |v| options[:title] = v }
|
40
|
+
end
|
41
|
+
|
42
|
+
def extract_options
|
43
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
44
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
45
|
+
# raw instance variable value.
|
46
|
+
@title = options[:title] || "Reactive Application"
|
47
|
+
@app_name = options[:app_name] || "Reactive Application"
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ApplicationHelper
|
2
|
+
|
3
|
+
class MainFrame < Reactive::View::Wx::Helpers::ModelMainFrame
|
4
|
+
def initialize(*args)
|
5
|
+
super
|
6
|
+
|
7
|
+
# Add your own panes here
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class RecordToolbarArtProvider < Wx::ArtProvider
|
12
|
+
def create_bitmap(id, client, size)
|
13
|
+
if id =~ /^record_(\w+)/
|
14
|
+
pathname = Reactive::View::Base.asset_pathname_for("#{$1}16.png")
|
15
|
+
pathname ? Wx::Bitmap.new(pathname, Wx::BITMAP_TYPE_PNG) : nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# shortcut
|
21
|
+
def current_page
|
22
|
+
Wx::get_app.top_window.current_page
|
23
|
+
end
|
24
|
+
|
25
|
+
# shortcut
|
26
|
+
def add_page(options = {}, &block)
|
27
|
+
Wx::get_app.top_window.add_page(options, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
# shortcut
|
31
|
+
def add_pane(options = {}, &block)
|
32
|
+
Wx::get_app.top_window.add_pane(options, &block)
|
33
|
+
end
|
34
|
+
|
35
|
+
# shortcut
|
36
|
+
def art_provider
|
37
|
+
Wx::get_app.top_window.art_provider
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# add the assets icons for the toolbar
|
3
|
+
#
|
4
|
+
art_provider.push(RecordToolbarArtProvider.new)
|
5
|
+
|
6
|
+
#
|
7
|
+
# create the toolbar with items
|
8
|
+
#
|
9
|
+
toolbar = Wx::ToolBar.new(frame, :style => Wx::TB_FLAT|Wx::TB_NODIVIDER|Wx::TB_TEXT)
|
10
|
+
toolbar.set_tool_bitmap_size( Wx::Size.new(32,32) )
|
11
|
+
|
12
|
+
toolbar.add_tool(1001, "New", art_provider.get_bitmap(Wx::ART_NEW, Wx::ART_TOOLBAR), "New record")
|
13
|
+
toolbar.add_tool(1002, "Show", art_provider.get_bitmap('record_show', Wx::ART_TOOLBAR), "Show record")
|
14
|
+
toolbar.add_tool(1003, "Edit", art_provider.get_bitmap('record_edit', Wx::ART_TOOLBAR), "Edit record")
|
15
|
+
toolbar.add_tool(1004, "Delete", art_provider.get_bitmap('record_delete', Wx::ART_TOOLBAR), "Delete record")
|
16
|
+
|
17
|
+
#
|
18
|
+
# bind request to each toolbar item
|
19
|
+
#
|
20
|
+
frame.evt_tool(1001) { do_request(:controller => frame.model.to_s.tableize, :action => 'new') if frame.model }
|
21
|
+
|
22
|
+
frame.evt_tool(1002) do
|
23
|
+
if (count = frame.selected_records.size) < 3 || Wx::YES == Wx::message_box("Show those #{count} records?", "<%= app_name %>", Wx::YES_NO)
|
24
|
+
frame.selected_records.each do |record|
|
25
|
+
do_request(:controller => record.class.to_s.tableize, :action => 'show', :id => record.id)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
frame.evt_tool(1003) do
|
31
|
+
if (count = frame.selected_records.size) < 3 || Wx::YES == Wx::message_box("Edit those #{count} records?", "<%= app_name %>", Wx::YES_NO)
|
32
|
+
frame.selected_records.each do |record|
|
33
|
+
do_request(:controller => record.class.to_s.tableize, :action => 'edit', :id => record.id)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
frame.evt_tool(1004) do
|
39
|
+
do_request(:controller => frame.model.to_s.tableize, :action => 'delete', :id => frame.selected_records.map(&:id)) unless frame.selected_records.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# add the toolbar to the frame
|
44
|
+
#
|
45
|
+
toolbar.realize
|
46
|
+
frame.add_pane(:name => "record_tb", :caption => "Record actions", :left_dockable => false, :right_dockable => false) {|info| info.toolbar_pane.top; toolbar}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Description:
|
2
|
+
Scaffolds the views for a given model. Views for all CRUD operations
|
3
|
+
are done, respecting the following action names:
|
4
|
+
index, show, new, create, edit, update, delete, destroy
|
5
|
+
|
6
|
+
Pass the name of the model, either CamelCased or under_scored, as the
|
7
|
+
first argument.
|
8
|
+
|
9
|
+
You don't need to pass attributes, the scaffolds will infer them from the
|
10
|
+
database.
|
11
|
+
|
12
|
+
Note that this generator is also used automatically when running the
|
13
|
+
`scaffold` generator.
|
14
|
+
|
15
|
+
Example:
|
16
|
+
`./script/generate scaffold product`
|
@@ -0,0 +1 @@
|
|
1
|
+
book.delete_page(book.get_page_index(page))
|
@@ -0,0 +1,3 @@
|
|
1
|
+
if !@<%= controller_plural_name %>.empty? && Wx::YES == Wx::message_box("Delete <%= model_name.humanize %>:\n#{@<%= controller_plural_name %>.join(%Q(\n))}\nAre you sure?", "<%= app_name %>", Wx::YES_NO)
|
2
|
+
do_request(:controller => '<%= controller_underscore_name %>', :action => 'destroy', :id => @<%= controller_plural_name %>.map(&:id))
|
3
|
+
end
|
File without changes
|
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
if local_assigns.has_key? :page
|
3
|
+
page.show_errors(@<%= controller_singular_name %>)
|
4
|
+
else
|
5
|
+
add_page(:caption => "Edit <%= controller_singular_name.humanize %>: #{@<%= controller_singular_name %>}") do |book|
|
6
|
+
ModelEditCtrl.new(book, @<%= controller_singular_name %>, {:controller => '<%= controller_underscore_name %>', :action => 'update', :id => @<%= controller_singular_name %>.id })
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
if local_assigns.has_key? :page
|
3
|
+
page.show_errors(@<%= controller_singular_name %>)
|
4
|
+
else
|
5
|
+
add_page(:caption => "New <%= controller_singular_name.humanize %>") do |book|
|
6
|
+
ModelEditCtrl.new(book, @<%= controller_singular_name %>, {:controller => '<%= controller_underscore_name %>', :action => 'create'})
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
book.delete_page(book.get_page_index(page))
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'named_base_generator'
|
2
|
+
|
3
|
+
class ViewGenerator < Reactive::NamedBaseGenerator
|
4
|
+
default_options :skip_timestamps => false, :skip_migration => false
|
5
|
+
|
6
|
+
attr_reader :controller_name,
|
7
|
+
:controller_class_path,
|
8
|
+
:controller_file_path,
|
9
|
+
:controller_class_nesting,
|
10
|
+
:controller_class_nesting_depth,
|
11
|
+
:controller_class_name,
|
12
|
+
:controller_underscore_name,
|
13
|
+
:controller_plural_name,
|
14
|
+
:controller_singular_name
|
15
|
+
alias_method :controller_file_name, :controller_underscore_name
|
16
|
+
alias_method :controller_table_name, :controller_plural_name
|
17
|
+
|
18
|
+
attr_reader :app_name
|
19
|
+
|
20
|
+
def initialize(runtime_args, runtime_options = {})
|
21
|
+
super
|
22
|
+
|
23
|
+
@controller_name = @name.pluralize
|
24
|
+
|
25
|
+
base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
|
26
|
+
@controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
|
27
|
+
@controller_singular_name = @controller_plural_name.singularize
|
28
|
+
|
29
|
+
extract_options
|
30
|
+
end
|
31
|
+
|
32
|
+
def manifest
|
33
|
+
record do |m|
|
34
|
+
m.directory(File.join('app/views', controller_class_path, controller_file_name))
|
35
|
+
|
36
|
+
for action in scaffold_views
|
37
|
+
m.template(
|
38
|
+
"#{action}.rb",
|
39
|
+
File.join('app/views', controller_class_path, controller_file_name, "#{action}.rb")
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
# Override with your own usage banner.
|
48
|
+
def banner
|
49
|
+
"Usage: #{$0} view ModelName"
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_options!(opts)
|
53
|
+
opts.separator ''
|
54
|
+
opts.separator 'Options:'
|
55
|
+
opts.on("-n", "--name=\"App name\"", "Specifies the application name. Used in message boxes.") { |v| options[:app_name] = v }
|
56
|
+
end
|
57
|
+
|
58
|
+
def scaffold_views
|
59
|
+
%w[ index show new create edit update delete destroy ]
|
60
|
+
end
|
61
|
+
|
62
|
+
def model_name
|
63
|
+
class_name.demodulize
|
64
|
+
end
|
65
|
+
|
66
|
+
def extract_options
|
67
|
+
@app_name = options[:app_name] || "Reactive Application"
|
68
|
+
end
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: reactive_view_wx
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pascal Hurni
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-14 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: reactive
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.1.0
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: activesupport
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 1.4.0
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: actionpack
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.0.0
|
41
|
+
version:
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: wxruby
|
44
|
+
version_requirement:
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.9.4
|
50
|
+
version:
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: wx_sugar
|
53
|
+
version_requirement:
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 0.1.19
|
59
|
+
version:
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: hoe
|
62
|
+
version_requirement:
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.5.1
|
68
|
+
version:
|
69
|
+
description: This is a view provider for Reactive, the desktop application framework, it provides views based on the wxWidgets library. For this the ruby port wxRuby is used.
|
70
|
+
email:
|
71
|
+
- phi@ruby-reactive.org
|
72
|
+
executables: []
|
73
|
+
|
74
|
+
extensions: []
|
75
|
+
|
76
|
+
extra_rdoc_files:
|
77
|
+
- History.txt
|
78
|
+
- Manifest.txt
|
79
|
+
- README.txt
|
80
|
+
files:
|
81
|
+
- History.txt
|
82
|
+
- MIT-LICENSE
|
83
|
+
- Manifest.txt
|
84
|
+
- README.txt
|
85
|
+
- Rakefile
|
86
|
+
- lib/action_view_init.rb
|
87
|
+
- lib/base.rb
|
88
|
+
- lib/binder.rb
|
89
|
+
- lib/helpers/model_edit_ctrl_class.rb
|
90
|
+
- lib/helpers/model_list_ctrl_class.rb
|
91
|
+
- lib/helpers/model_main_frame_class.rb
|
92
|
+
- lib/helpers/model_show_ctrl_class.rb
|
93
|
+
- lib/reactive_view_wx.rb
|
94
|
+
- lib/request.rb
|
95
|
+
- lib/template.rb
|
96
|
+
- lib/version.rb
|
97
|
+
- lib/xrc_pepper.rb
|
98
|
+
- reactive_generators/application_view/USAGE
|
99
|
+
- reactive_generators/application_view/application_view_generator.rb
|
100
|
+
- reactive_generators/application_view/templates/application_helper.rb
|
101
|
+
- reactive_generators/application_view/templates/application_layout.rb
|
102
|
+
- reactive_generators/application_view/templates/application_view.rb
|
103
|
+
- reactive_generators/application_view/templates/assets/delete16.png
|
104
|
+
- reactive_generators/application_view/templates/assets/edit16.png
|
105
|
+
- reactive_generators/application_view/templates/assets/show16.png
|
106
|
+
- reactive_generators/application_view/templates/record_toolbar.rb
|
107
|
+
- reactive_generators/view/USAGE
|
108
|
+
- reactive_generators/view/templates/create.rb
|
109
|
+
- reactive_generators/view/templates/delete.rb
|
110
|
+
- reactive_generators/view/templates/destroy.rb
|
111
|
+
- reactive_generators/view/templates/edit.rb
|
112
|
+
- reactive_generators/view/templates/index.rb
|
113
|
+
- reactive_generators/view/templates/layout.rb
|
114
|
+
- reactive_generators/view/templates/new.rb
|
115
|
+
- reactive_generators/view/templates/show.rb
|
116
|
+
- reactive_generators/view/templates/update.rb
|
117
|
+
- reactive_generators/view/view_generator.rb
|
118
|
+
has_rdoc: true
|
119
|
+
homepage: Please visit www.ruby-reactive.org for further informations.
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options:
|
122
|
+
- --main
|
123
|
+
- README.txt
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: "0"
|
131
|
+
version:
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: "0"
|
137
|
+
version:
|
138
|
+
requirements: []
|
139
|
+
|
140
|
+
rubyforge_project: reactive_view_wx
|
141
|
+
rubygems_version: 1.0.1
|
142
|
+
signing_key:
|
143
|
+
specification_version: 2
|
144
|
+
summary: This is a view provider for Reactive, the desktop application framework, it provides views based on the wxWidgets library
|
145
|
+
test_files: []
|
146
|
+
|