lustr-jruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +17 -0
- data/README.txt +5 -0
- data/Rakefile +93 -0
- data/lib/lustr-jruby.rb +17 -0
- data/lib/lustr-jruby/_common.rb +48 -0
- data/lib/lustr-jruby/app.rb +51 -0
- data/lib/lustr-jruby/box.rb +37 -0
- data/lib/lustr-jruby/button.rb +33 -0
- data/lib/lustr-jruby/divided_box.rb +41 -0
- data/lib/lustr-jruby/field.rb +36 -0
- data/lib/lustr-jruby/label.rb +32 -0
- data/lib/lustr-jruby/list.rb +31 -0
- data/lib/lustr-jruby/version.rb +24 -0
- data/scripts/txt2html +67 -0
- data/setup.rb +1585 -0
- metadata +69 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
lib/lustr-jruby.rb
|
6
|
+
lib/lustr-jruby/version.rb
|
7
|
+
lib/lustr-jruby/button.rb
|
8
|
+
lib/lustr-jruby/box.rb
|
9
|
+
lib/lustr-jruby/app.rb
|
10
|
+
lib/lustr-jruby/field.rb
|
11
|
+
lib/lustr-jruby/label.rb
|
12
|
+
lib/lustr-jruby/list.rb
|
13
|
+
lib/lustr-jruby/divided_box.rb
|
14
|
+
lib/lustr-jruby/_common.rb
|
15
|
+
scripts/txt2html
|
16
|
+
setup.rb
|
17
|
+
|
data/README.txt
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Lustr is a Ruby DSL for GUI development. Lustr4JRuby allows Lustr UIs to be
|
2
|
+
displayed via JRuby/Swing.
|
3
|
+
|
4
|
+
More details on Lustr can be found at {Lustr's home page}[http://www.codecorps.org/moinmoin/index.cgi/Lustr]
|
5
|
+
or on the {RubyForge}[http://rubyforge.org/projects/lustr] site.
|
data/Rakefile
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'hoe'
|
11
|
+
include FileUtils
|
12
|
+
require File.join(File.dirname(__FILE__), 'lib', 'lustr-jruby', 'version')
|
13
|
+
|
14
|
+
AUTHOR = 'Makr Murphy' # can also be an array of Authors
|
15
|
+
EMAIL = "mmurphy@municorps.org"
|
16
|
+
DESCRIPTION = "Lustr support for JRuby/Swing"
|
17
|
+
GEM_NAME = 'lustr-jruby' # what ppl will type to install your gem
|
18
|
+
RUBYFORGE_PROJECT = 'lustr' # The unix name for your project
|
19
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
20
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
21
|
+
|
22
|
+
NAME = "lustr-jruby"
|
23
|
+
REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
24
|
+
VERS = Lustr4JRuby::VERSION::STRING + (REV ? ".#{REV}" : "")
|
25
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
|
26
|
+
RDOC_OPTS = ['--quiet', '--title', 'lustr-jruby documentation',
|
27
|
+
"--opname", "index.html",
|
28
|
+
"--line-numbers",
|
29
|
+
"--main", "README",
|
30
|
+
"--inline-source"]
|
31
|
+
|
32
|
+
class Hoe
|
33
|
+
def extra_deps
|
34
|
+
@extra_deps.reject { |x| Array(x).first == 'hoe' }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Generate all the Rake tasks
|
39
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
40
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
41
|
+
p.author = AUTHOR
|
42
|
+
p.description = DESCRIPTION
|
43
|
+
p.email = EMAIL
|
44
|
+
p.summary = DESCRIPTION
|
45
|
+
p.url = HOMEPATH
|
46
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
47
|
+
p.test_globs = ["test/**/test_*.rb"]
|
48
|
+
p.clean_globs = CLEAN #An array of file patterns to delete on clean.
|
49
|
+
|
50
|
+
# == Optional
|
51
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
52
|
+
p.extra_deps = [['lustr-core', '>=0.1']] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
53
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
desc 'Generate website files'
|
58
|
+
task :website_generate do
|
59
|
+
Dir['website/**/*.txt'].each do |txt|
|
60
|
+
sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc 'Upload website files to rubyforge'
|
65
|
+
task :website_upload do
|
66
|
+
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
67
|
+
host = "#{config["username"]}@rubyforge.org"
|
68
|
+
remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
|
69
|
+
# remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
70
|
+
local_dir = 'website'
|
71
|
+
sh %{rsync -av #{local_dir}/ #{host}:#{remote_dir}}
|
72
|
+
end
|
73
|
+
|
74
|
+
desc 'Generate and upload website files'
|
75
|
+
task :website => [:website_generate, :website_upload]
|
76
|
+
|
77
|
+
desc 'Release the website and new gem version'
|
78
|
+
task :deploy => [:check_version, :website, :release]
|
79
|
+
|
80
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
81
|
+
task :local_deploy => [:website_generate, :install_gem]
|
82
|
+
|
83
|
+
task :check_version do
|
84
|
+
unless ENV['VERSION']
|
85
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
86
|
+
exit
|
87
|
+
end
|
88
|
+
unless ENV['VERSION'] == VERS
|
89
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
90
|
+
exit
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
data/lib/lustr-jruby.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
path=File::join(File::dirname(__FILE__), 'lustr-jruby')
|
17
|
+
Dir[path+'/*.rb'].sort.each {|f| require f}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
require 'lustr'
|
17
|
+
require 'java'
|
18
|
+
|
19
|
+
module Lustr4JRuby
|
20
|
+
class BlockActionListener < java.awt.event.ActionListener
|
21
|
+
def initialize(&block)
|
22
|
+
@block=block
|
23
|
+
end
|
24
|
+
|
25
|
+
def actionPerformed(event)
|
26
|
+
@block.call(event)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class SimpleDocumentListener < javax.swing.event.DocumentListener
|
31
|
+
def initialize(&block)
|
32
|
+
@on_change_block=block
|
33
|
+
end
|
34
|
+
|
35
|
+
def insertUpdate(e)
|
36
|
+
@on_change_block.call(:insert, e)
|
37
|
+
end
|
38
|
+
|
39
|
+
def removeUpdate(e)
|
40
|
+
@on_change_block.call(:remove, e)
|
41
|
+
end
|
42
|
+
|
43
|
+
def changedUpdate(e)
|
44
|
+
@on_change_block.call(:change, e)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
require 'lustr'
|
17
|
+
require 'java'
|
18
|
+
|
19
|
+
module Lustr4JRuby
|
20
|
+
class App < java.lang.Runnable
|
21
|
+
include Lustr::WidgetBase
|
22
|
+
|
23
|
+
def init_options(options)
|
24
|
+
super
|
25
|
+
|
26
|
+
self.controller=option(:controller) if option(:controller)
|
27
|
+
@frame=javax.swing.JFrame.new option(:title)
|
28
|
+
@panel=javax.swing.JPanel.new
|
29
|
+
@panel.layout=javax.swing.BoxLayout.new(@panel, javax.swing.BoxLayout::Y_AXIS)
|
30
|
+
@frame.add(@panel)
|
31
|
+
@frame.set_size option(:width), option(:height)
|
32
|
+
@frame.set_default_close_operation javax.swing.JFrame::EXIT_ON_CLOSE
|
33
|
+
end
|
34
|
+
|
35
|
+
def <<(c)
|
36
|
+
super
|
37
|
+
@panel.add(c.resolve)
|
38
|
+
end
|
39
|
+
|
40
|
+
def render
|
41
|
+
javax.swing.SwingUtilities.invokeLater(self)
|
42
|
+
end
|
43
|
+
|
44
|
+
def show
|
45
|
+
@frame.visible=true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
Lustr.declare(Lustr::SimpleBuilder.new(:app, Lustr4JRuby::App))
|
51
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
require 'lustr'
|
17
|
+
require 'java'
|
18
|
+
|
19
|
+
module Lustr4JRuby
|
20
|
+
class Box < javax.swing.Box
|
21
|
+
include Lustr::WidgetBase
|
22
|
+
def <<(child)
|
23
|
+
super
|
24
|
+
add(child)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class BoxBuilder < Lustr::BuilderBase
|
29
|
+
def build(parent_widget)
|
30
|
+
direction=(options[:direction]==:vertical ? javax.swing.BoxLayout::Y_AXIS : javax.swing.BoxLayout::X_AXIS)
|
31
|
+
Box.new(direction)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Lustr.declare(Lustr4JRuby::BoxBuilder.new(:box))
|
37
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
require 'lustr'
|
17
|
+
require 'java'
|
18
|
+
|
19
|
+
module Lustr4JRuby
|
20
|
+
class Button < javax.swing.JButton
|
21
|
+
include Lustr::WidgetBase
|
22
|
+
|
23
|
+
def init_options(options)
|
24
|
+
super
|
25
|
+
|
26
|
+
self.text=option(:text)
|
27
|
+
add_action_listener BlockActionListener.new { raise_event(option(:on_click)) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Lustr.declare(Lustr::SimpleBuilder.new(:button, Lustr4JRuby::Button))
|
33
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
require 'lustr'
|
17
|
+
require 'java'
|
18
|
+
|
19
|
+
module Lustr4JRuby
|
20
|
+
class DividedBoxWidget < javax.swing.JSplitPane
|
21
|
+
include Lustr::WidgetBase
|
22
|
+
|
23
|
+
def init_options(options)
|
24
|
+
super
|
25
|
+
|
26
|
+
self.orientation=(option(:direction)==:vertical ? JSplitPane::VERTICAL_SPLIT : JSplitPane::HORIZONTAL_SPLIT)
|
27
|
+
end
|
28
|
+
|
29
|
+
def <<(child)
|
30
|
+
super
|
31
|
+
|
32
|
+
if children.size==2
|
33
|
+
self.left_component=children[0].resolve
|
34
|
+
self.right_component=children[1].resolve
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Lustr.declare(Lustr::SimpleBuilder.new(:divided_box, Lustr4JRuby::DividedBoxWidget))
|
41
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
require 'lustr'
|
17
|
+
require 'java'
|
18
|
+
|
19
|
+
module Lustr4JRuby
|
20
|
+
class Field < javax.swing.JTextField
|
21
|
+
include Lustr::WidgetBase
|
22
|
+
|
23
|
+
def init_options(options)
|
24
|
+
super
|
25
|
+
|
26
|
+
document.add_document_listener SimpleDocumentListener.new { raise_event(option(:on_change)) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def text=(text)
|
30
|
+
self.set_text text
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Lustr.declare(Lustr::SimpleBuilder.new(:field, Lustr4JRuby::Field))
|
36
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
require 'lustr'
|
17
|
+
require 'java'
|
18
|
+
|
19
|
+
module Lustr4JRuby
|
20
|
+
class Label < javax.swing.JLabel
|
21
|
+
include Lustr::WidgetBase
|
22
|
+
|
23
|
+
def init_options(options)
|
24
|
+
super
|
25
|
+
|
26
|
+
self.text=option(:text)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Lustr.declare(Lustr::SimpleBuilder.new(:label, Lustr4JRuby::Label))
|
32
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
require 'lustr'
|
17
|
+
require 'java'
|
18
|
+
|
19
|
+
module Lustr4JRuby
|
20
|
+
class ListWidget < javax.swing.JScrollPane
|
21
|
+
include Lustr::WidgetBase
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@list=JList.new
|
25
|
+
super(@list)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Lustr.declare(Lustr::SimpleBuilder.new(:list, Lustr4JRuby::ListWidget))
|
31
|
+
|